Python Flask minimal


Create an environment
python3 -m venv venv

Activate the environment
. venv/bin/activate

Deactivate the environment

Install Flask
pip install Flask

# Import the Flask class - an instance of this class
# will be a WSGI application.

from flask import Flask

# Next we create an instance of this class. The first
# argument is the name of the application’s module or
# package. __name__ is a convenient shortcut for this
# that is appropriate for most cases. This is needed so
# that Flask knows where to look for resources such as
# templates and static files.

app = Flask(__name__)

def hello_world():
    return "<p>Hello, World!</p>"

export FLASK_APP=hello
flask run

If debugger disabled or you trust the users on your network, make the server publicly available
flask run --host=

The debugger allows executing arbitrary Python code from the browser. It is protected by a pin, but still represents a major security risk.
export FLASK_ENV=development
flask run