Home / Flask Beginner
Flask Beginner
Flask from a first route to a finished guestbook: routes, requests, templates, forms, sessions and blueprints. Every example runs for real against Flask.
Flask is the Python library for building websites. From a first route to a finished guestbook app, in fifty short lessons. Every example runs for real against Flask.
Course contents
Work top to bottom β the sidebar is the course. Topics later in the list assume the ones before them.
Getting Started
Start: Flask Introduction β―Routes
Start: Flask Routes β―Requests
- The Flask Request Object
- Flask Query Strings
- Flask Form Data
- Flask JSON Requests
- Flask Request Headers
Responses
Start: Flask Responses β―Templates
- Your First Flask Template
- Flask Template Variables
- Flask Template Loops
- Flask Template Conditions
- Flask Template Inheritance
- The Flask Templates Folder
- Escaping in Flask Templates
Forms
- Flask HTML Forms
- Handling Flask Form Posts
- Validating Flask Forms
- Redirect After Post in Flask
- Flask Flash Messages
Static Files
Start: The Flask Static Folder β―Sessions and Cookies
Start: The Flask Secret Key β―Errors
Start: Handling Flask 404 Errors β―Blueprints
Start: What Is a Flask Blueprint β―Structure and Config
Start: Flask App Config β―APIs and Finishing
Start: Building a Flask JSON API β―Learn Flask
Flask is a Python library for building websites. A browser asks for an address, and a Flask view answers with a page. The library handles the web plumbing, and your code decides what each address returns. Routes name the addresses, views build the answers, and templates hold the pages.
The course builds one skill at a time, in the order the ideas need each other. Routes open the course, then requests and responses, then templates. Forms follow, with the redirect that stops double sends, then static files, sessions, and error pages. Blueprints, config, and the app factory close the main teaching. A JSON API lesson leads into the guestbook capstone. There the pieces join into one working app.
Twelve groups hold the fifty lessons. Every closing example is a complete program, checked with the Flask test client, which calls the app without a server. The output shown matches the output the run gave. The test client is the course workbench. It asks for addresses, posts forms, and reads cookies, all inside one Python file.
What you will learn
Here are the 50 lessons in teaching order:
- Make a Flask app and serve it with the development server
- Answer addresses with routes, variables, and converters
- Build addresses with url_for and answer GET and POST
- Read query strings, form data, JSON, and headers from the request
- Return pages with status codes, headers, redirects, and JSON
- Render templates with variables, loops, and conditions
- Share a layout with template inheritance and the templates folder
- Keep typed text safe with escaping, and use |safe with care
- Build HTML forms, read posts, and validate the values
- Stop double sends with redirect after post, and flash one-time notes
- Serve CSS and images from the static folder
- Remember readers with sessions, cookies, and a simple login
- Answer missing pages with custom 404 pages and abort
- Split an app into blueprints, configure it, and shape a JSON API
- Finish a guestbook app that ties the course together
Who this Flask course is for
No web knowledge is assumed. The opening lessons explain what a request is before any route answers one. Each new term is defined inside the example that needs it. Some Python helps: variables, functions, lists, and dicts. Without that Python, start with the Python Beginner course.
The lessons add up to four hours and nine minutes. The forms and sessions lessons slow most readers down. That is normal. Those lessons repay a second read.
Students heading toward web work will find the opening lessons familiar ground for bigger frameworks later. Hobbyists with a small site in mind get the grounding a Flask app expects. Readers coming from another language meet the same ideas. Routes, templates, and sessions are spelled out in Python rather than in framework jargon.
How this course works
Every example runs for real against Flask 3.1.3. The output shown matches the output the run gave. The test client does the asking, so no lesson needs a running server to prove its point. The one server lesson starts the real development server under a timeout and quotes the startup lines it prints.
Each lesson closes with a running program and one question. The teaching order stays fixed. Forms make little sense before requests land. Sessions make little sense before cookies land. Progress stays in this browser, on the machine you used. No account is needed, and no lesson carries a charge.
Frequently asked questions
Do I need to know Python first?
Yes, a little Python first: variables, functions, dicts, and lists, at the level of the Python Beginner course. Flask itself is taught from zero. No web knowledge is assumed, and every web term is defined where it first appears.
What setup do I need before starting?
Python 3 and one install command, pip install flask. The second lesson shows the command, with a version check that proves the install worked. The examples run on your own computer after that install. The in-page runner cannot install Flask, so each lesson shows the output the example really gave when run against Flask.
How long is the course?
Fifty lessons totalling four hours and nine minutes of reading. Running the examples yourself takes roughly double that time. The guestbook capstone at the end counts in that total.
What is the hardest part of Flask?
The request and response cycle asks the most here. It covers what travels in a request and what a view must return. It also covers why a form post redirects instead of answering directly. The course holds those ideas until routes and the test client feel familiar. The redirect-after-post lesson is the one readers re-read most.
What can I do with Flask afterwards?
Build a small site or a JSON API of your own. Pages use templates, forms save values, logins remember a name, and blueprints keep a growing app tidy. The closing guestbook is a working model to copy. It holds messages, a form, and a redirect, ready to grow into your own project.
Is there a charge for the course?
No. All lessons are free to open, and no account is needed. Your place is saved on the device you used. Every lesson is free.
Next steps
- Python Beginner β― β Start here for the Python this course needs: 116 lessons, first program to files and classes.
- Python Intermediate β― β After Flask, grow the Python: 52 lessons on bigger programs, classes, files, and error handling.
- SQL β― β Give your Flask apps data to work with. The SQL course has 51 lessons on asking a database for answers with select, filter, joins, and window functions.