October 2018
Intermediate to advanced
332 pages
8h 9m
English
In order to make the next chapters easier for the reader, we will look at how to use the Flask CLI (using version 0.11 onward). The CLI allows programmers to create commands that act within the application context of Flask—that is, the state in Flask that allows the modification of the Flask object. The Flask CLI comes with some default commands to run the server and a Python shell in the application context.
Let's take a look at the Flask CLI and how to initialize it. First, we must tell it how to discover our application using the following code:
$ export FLASK_APP=main.py
Then, we will use the Flask CLI to run our application using the following code:
$ flask run
Now, let's enter the shell on ...