http server:
@app.route('/add', methods=['POST'])
def add():
result = {'sum': request.json['a'] + request.json['b'], 'product': request.json['a'] + request.json['b']}
return jsonify(result)
Client:
import requests
json_data = {'a': 1, 'b': 2}
r = requests.post("http://127.0.0.1:5000/add", json=json_data)
print(r.text)
How to run similar request from a browser? For example
http://localhost:5000/segment?text=this is a test
In the JSON post request, how to create the correct URL to send the parameter json_data to the server? I tried this but didn't work:
http://127.0.0.1:5000/add?json_data={'a': 1, 'b': 2}