The problem is you are only binding to the localhost interface, you should be binding to 0.0.0.0
if you want the container to be accessible from outside. If you change:
if __name__ == '__main__':
app.run()
to
if __name__ == '__main__':
app.run(host="0.0.0.0")
It should work.
Note that this will bind to all interfaces on the host, which may in some circumstances be a security risk – see https://stackoverflow.com/a/58138250/4332 for more information on binding to a specific interface.