Python Flask Introduction

Python Flask Introduction


Flask is a lightweight, WSGI web application framework. It was designed to make getting started quick and easy, with the ability to scale up to complex applications. It began as a simple wrapper around Werkzeug and Jinja and has become one of the most popular Python web application frameworks. 

Create an environment

Create a project folder and a venv folder within:

$ mkdir myproject
$ cd myproject

On Lunix

$ python -m venv venv

On Windows:

$ py -3 -m venv venv 

Activate the environment

On Lunix

$ . venv/bin/activate

On Windows:

$ venvScriptsactivate 

Install  Flask into the virtual environment

Install and update using pip:

$ pip install -U Flask

Installing using github:

$ pip install -U

A Simple Example

from flask import Flask
app = Flask(__name__)

app = Flask(__name__)
def hello():
return "Hello, World!"

Running the Application

On Windows

set FLASK_APP=hello
run flask


The default hosted address if and the default port is 5000

Next: Flask Basic Application structure