Code a simple app In Flask

How To code a simple Flask Application

This page explains how to code a simple Flask application.

Prerequisites

  • Basic programming knowledge in Python

  • Basic Flask knowledge

  • Comfortable using a terminal

A minimal app

Before using Flask, we need to install it. Open a terminal and type:

$ pip install Flask

Create a new file hello.py with the following content:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return f'Hello from Flask!'

Once the file is saved, let's start the app:

By visiting the app in the browser we should see "Hello from Flask" message.

Last updated

Was this helpful?