I have create a Flask Api (simple demo)
It will take a json and add those values and return addition.
Can anyone tell me how can i call that API with param?
please help me with this.
I have attached what I have done.
app = Flask(__name__)
@app.route('/add', methods=['POST'])
def add():
data = request.get_json()
return jsonify({'sum': data['x'] + data['x']})
app.run(port=5003)
when i used below code it gives an error OSError: [Errno 98] Address already in use
I used this code from diff .py file
url='http://127.0.0.1:5003/'
response = app.test_client().post(
'/add',
data=json.dumps({'x': 1, 'y': 2}),
content_type='application/json',
)
I want to call that API from diff .py file, this is what i want.
Thanks