I'm trying to make a POST request to a localhost address I've set inside the same python file but I am getting the error ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
Here's my code:
@app.route('/callback_work/', methods=['POST'])
async def callback_work():
content_type = request.headers.get('content-type')
if (content_type == 'application/json'):
request_json = await request.get_json()
print(request_json)
return 'Callback done'
else:
return 'Content-Type not supported!'
async def capture_callback(request_json):
requests.post('http://localhost:5000/callback_work/',
json=request_json, timeout=2, headers={"Content-Type": "application/json"})
I am already providing the request_json
through another function and I know it's valid and it exists. Also, I've been sending POST requests through Postman all of this time and everything was working fine. The timeout
argument is there as a precaution since I was executing the script without it and it never stopped waiting for the POST request to be executed.
Do you thing there's a problem that both the function that handles the post request and the function that makes the post request, are in the same file?