Flask App - First Run

This article describe the minimum required setup to have a running Flask application.


Project structure

The minimal project requires only two files: run.py (the app launcher) and __init__.py the init file for our app

<ROOT> / run.py
       / app /
       / app / __init__.py


The contents of run.py

from app import app

if __name__ == "__main__":
    app.run()


The contents of __init__.py

from app import app

if __name__ == "__main__":
    app.run()


Environment set up

Before running your app you must set the variable FLASK_APP, to inform Flask what should be executed first


Navigate to the directory where run.py was saved, and type flask run. By visiting locahost:5000 in your preferred browser you should see the app running.