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

python app.py

How to run flask application on port 80

To run flask application on port 80, use command

flask run --host 0.0.0.0 --port 80

Or edit app.py, use the following code

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=80)

Or you can use the following environment variables

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

flash run

It looks for app.py file. If you need to change the file name, you can use the environment variable

FLASK_APP=application.py

See python

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *