The Flask application on the external visible server development server can only be accessed on the computer where the development environment is set up.This is a default behavior because users can execute arbitrary code on a computer in debug mode.
If debug is disabled, the development server on the local computer can be made available to users on the network by setting the host name to ‘0.0.0.0’.
app.run(host = ’0.0.0.0’)
Therefore, your operating system will listen on all network IPs.
to switch from a development environment to a mature production environment requires that applications be deployed on a real Web server.
To deploy your Flask app, you can use PythonAnywhere.
This puts your app online, for anyone to access. They maintain the server for you, so you don’t have to. On top of that, it’s free for small apps.
If you insist on running your own server (with all the maintenance burden), you can do so with Apache. But, life is short and it’s easier to use PythonAnywhere.
To install the official release directly from PyPi, you can run:
pip install mod_wsgi
mod_wsgi is an Apache module that provides a WSGI compliant interface for hosting Python-based web applications on an Apache server.
To verify that the installation was successful, run the mod_wsgi-express script using the start-server command:
This will start Apache/mod_wsgi on port 8000.Then, you can verify that the installation is valid by pointing your browser to the following: localhost:8000/
The create .wsgi file should have a yourapplication.wsgi file.This file contains the code mod_wsgi, which is executed at startup time to get the application object.The following files should be sufficient for most applications:
from yourapplication import app as application
Ensure that yourapplication and all the libraries in use are on the python load path.
Configure Apache you need to tell mod_wsgi, where your application is located: