I tested the same code that you have pasted on my machine and it did work on my machine (windows 11). Now there could be two reasons. I would like you to go through the listed options below.
1. Add this two lines in your app.py: and build the image again to test
if _name_ == "_main_":
app.run(debug=True, host="0.0.0.0", port=5000)
2. Check your firewall settings
And if it still doesn't work, please go through the below Docker forum link:
https://forums.docker.com/t/docker-curl-56-recv-failure/54172/6