Key parts
In this very tiny app we encounter the absolutely essential parts to making a Flask application.
First we import the Flask library:
from flask import Flask
We set up our app variable, which is basically our app, to which you configure and add routes/controller and later extensions.
app = Flask(__name__)
Then we set up the controller for a route ('/') for our app:
@app.route('/')
def index():
return "Hello Flask!"
And that's it! Yes - you could add other small conventions (we will in later demos), but here we have a tiny bit of Python, which renders in a browser.
If you have not installed Python3, please do.
First create and activate some form of environment to store your dependencies. I like Conda:
$ conda create -n myenv python=3.7
$ conda activate myenv
Or just use Pythons built in environments:
$ python3 -m venv venv
$ . venv/bin/activate
Then install Flask
$ pip install Flask
$ flask run
You should now be able to see "Hello Flask!" in your browser window (at http://127.0.0.1:5000)