Flask

A small, explicit Python web framework.

Flask is taught here in 12 lessons, running from Your first Flask app through to Deployment: gunicorn, nginx and Docker. Each lesson takes one topic, shows the working code, and links onward to the next, so the course can be read straight through in order.

TrackPython & Data Science
Lessons12
LevelBeginner to intermediate
Reading timeabout 3 hours
PrerequisitesHelpful, but not required: Jupyter Notebook

Lessons

  1. Your first Flask appRoutes, view functions, the development server, and how Flask decides which function handles a request.
  2. Templates with Jinja2Passing data into templates, inheritance with blocks, escaping (and the one line that disables it).
  3. Forms, sessions and errorsReading request data, validating it, flashing messages, keeping a session, and returning sensible error responses.
  4. Routing in depth: converters, methods and url_forUse URL converters well, handle HTTP methods and trailing slashes deliberately, and build every link from an endpoint name instead of a hard-coded path.
  5. Blueprints and the application factorySplit a growing app into blueprints, build the app inside create_app() for testability, and initialise extensions without circular imports.
  6. Configuration and project structureOrganise config as classes, read secrets from the environment, keep machine-specific files in the instance folder, and make development and production differ only where they must.
  7. Databases with Flask-SQLAlchemyDefine models, query them through the session, handle transactions without leaving the session broken, and avoid the lazy-loading traps that make pages slow.
  8. Schema migrations with Flask-MigrateInitialise Alembic through Flask-Migrate, review the scripts autogenerate produces, and apply schema and data changes in a controlled order.
  9. Authentication with Flask-Login and password hashingGive users real passwords with Werkzeug hashing, keep them signed in with Flask-Login, protect routes, and gate features by role without breaking open redirects.
  10. Building and testing a JSON APIReturn consistent JSON with honest status codes, then test the contract with the test client, fixtures and a database that is not the one you develop on.
  11. File uploads, static files and sending emailAccept uploads without writing an attacker-controlled filename, cache static assets correctly, and send mail without blocking the request that triggered it.
  12. Deployment: gunicorn, nginx and DockerRun Flask under a real WSGI server, put nginx in front for TLS and static files, and containerise the app without baking secrets into the image.

More in Python & Data Science

Python 3 NumPy pandas Matplotlib Jupyter Notebook FastAPI Django SciPy Pillow Python 2.x R Julia

FAQ

How long does the Flask course take?
It has 12 lessons, about 3 hours of reading. Expect roughly twice that if you type out and run every example.
Do I need prior experience for Flask?
Not strictly. It helps to have read Jupyter Notebook first, because some lessons build on it, but every lesson explains its own assumptions.
What should I read after Flask?
Continue with FastAPI (3 lessons), the next course in Python & Data Science.

Last refreshed 2026-09-18.