Learning Flask: Part 1: Installing and Using

Learning Flask

Flask is a microframework for server-side web development in Python.


Flask is available as part of PIP. With Python installed, PIP can be added (if an older version of Python is installed).

pip install flask


Flask can be run in two different default ways: via server variables or in script execution mode.

Server Variables

The Flask documentation recommends setting an environmental variable called FLASK_APP and setting it to the name of the file containing the Python code.

Once set, the command “flask run” can be used to run the script set to this value. This is the recommended production usage.

FLASK_APP=hello.py flask run

Script Execution Mode

For development settings and purposes, Flask can be run through the command-line usage of including the following:

from flask import Flask
app = Flask(name)
# Code here
if name == 'main':

When started through the run() function, Flask will run in development mode.

Play with the example on Repl.it!