-1

I have hosted my files on a remote flask server. Started the server using: flask run --host= ...

In the python code inside app, app.run(host='0.0.0.0')

The server starts without any issue but I am unable to access the page remotely.

I checked the ports as well. No problem there.

davidism
  • 121,510
  • 29
  • 395
  • 339

1 Answers1

1

You aren't supposed to use the built-in 'app' to host your server. Instead, use a reverse proxy like Gunicorn+Nginx

An effortless solution is to use PythonAnywhere (see https://help.pythonanywhere.com/pages/Flask/), but it obviously has limitations.

Also: there isn't just one solution available for this problem. There are plenty, for example: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uswgi-and-nginx-on-ubuntu-18-04 or https://dev.to/ishankhare07/nginx-as-reverse-proxy-for-a-flask-app-using-docker-3ajg

To visualize what your server can look like, see:

enter image description here

Zun
  • 1,553
  • 3
  • 15
  • 26