Flask Python framework
Flask is a Python framework. You can find more info at the official website.
https://flask.palletsprojects.com/
How to start a Flask application?
To start flask application, run
1 |
python app.py |
How to run flask application on port 80
To run flask application on port 80, use command
1 |
flask run --host 0.0.0.0 --port 80 |
Or edit app.py, use the following code
1 2 |
if __name__ == '__main__': app.run(host='0.0.0.0', port=80) |
Or you can use the following environment variables
1 2 |
FLASK_RUN_HOST=0.0.0.0 FLASK_RUN_PORT=80 |
Port 80 can only be used by the root user, so you need to run the above command as root. Only do this for testing as it is insecure to run an application as the root user.
Default flask app name
When you run
1 |
flash run |
It looks for app.py file. If you need to change the file name, you can use the environment variable
1 |
FLASK_APP=application.py |
See python