Flask Hello World


Example

Create hello.py:

from flask import Flask

app = Flask(__name__)


@app.route('/')
def hello():
    return 'Hello, World!'

Then run it with:

export FLASK_APP=hello.py
flask run
 * Running on http://localhost:5000/

Adding the code below will allow running it directly with python hello.py.

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