Basics of Flask

This Flask file illustrates the fundamentals.

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello_world():
    return "Hello, World!"

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

To run the app, we need the following:

  • The Main Guard
  • Export the $FLASK_APP system variable
export FLASK_APP=/path/from/current/directory/to/file.py flask run


all tags