Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Requests Post is Stuck at Starting New HTTP Connection

user_info = json.dumps({"bio":biography, "interests":interest_indexes})
headers = {'Content-type':'application/json'}
url = "http://0.0.0.0:5000/users/" + str(user_id)
r = requests.post("http://0.0.0.0:5000/users/1", data=user_info, headers=headers)

I've enabled logging and this is in Flask. If I manually do a POST request to the URL with the correct JSON response body, it works fine. It just says INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 0.0.0.0

And it just hangs there forever.

Any ideas?

like image 661
user3084415 Avatar asked Apr 10 '26 18:04

user3084415


1 Answers

You need to run your flask app with threading enabled.

app.run(threaded=True)

This is not advisable for production of course, just for quick development :)

like image 94
nasser alshammari Avatar answered Apr 13 '26 07:04

nasser alshammari



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!