Flask Web Development
Build a real web app with Flask: routes, Jinja templates, forms, a database, logins, a JSON API, tests and deployment. Decorators explained properly.
- 0 students
- 105 lessons
- 8 h 50 min
Created by Ayim Nelson
What you will learn
- Write and use Python decorators, including ones that take arguments
- Build Flask routes, read requests and send responses, redirects and errors
- Make pages with Jinja templates, inheritance, filters and static files
- Handle forms safely with Flask-WTF, validation, CSRF and flash messages
- Structure an app with blueprints, an application factory and config
- Store data with Flask-SQLAlchemy and Flask-Migrate, and log users in with Flask-Login
- Build a JSON API, test everything with pytest and deploy with Gunicorn
- Choose between Flask and Django for a project
About this course
Flask is a small Python web framework: it gives you routing and templates, and you add the rest when you need it. In this course you build the Tamale Notice Board, a community board for churches, mosques and groups in Tamale, from a five-line app to a tested website with accounts and a JSON API. Along the way you learn Python decorators properly, because Flask's @app.route is one. Every response, command and test run you see came from running the real code on Flask 3.1.
For: anyone who has finished the Python Crash Course, or knows functions, dictionaries and classes. How the Web Works helps but isn't required. You'll work on your own computer with Python 3.11 or newer; the exercises run right here in the browser.
By the end: you'll have built a notice board where people sign up, log in, post and remove their own notices, filter them by category and read them as JSON, with a database, migrations, tests and a production server, and you'll know when to pick Flask or Django.
Course content
11 sections · 105 lessons
Getting started with Flask9 lessons
- What Flask isPreviewReading · 3 min
- What you'll build: the Tamale Notice BoardPreviewReading · 3 min
- How Flask answers a requestPreviewReading · 4 min
- Installing FlaskReading · 4 min
- Your first Flask appReading · 4 min
- Running the development serverReading · 4 min
- Debug modeReading · 4 min
- Listing your routesReading · 3 min
- A tiny route tableExercise · 10 min
Decorators: how @app.route works10 lessons
- Functions are valuesReading · 4 min
- Functions inside functionsReading · 4 min
- Your first decoratorReading · 4 min
- The @ syntaxReading · 3 min
- Wrapping any function with *args and **kwargsReading · 4 min
- Keeping the name with functools.wrapsReading · 4 min
- Decorators that take argumentsReading · 5 min
- Stacking decoratorsReading · 3 min
- A decorator that registers: @app.routeReading · 5 min
- Build your own @routeExercise · 14 min
Routes, requests and responses9 lessons
- Variable rulesReading · 4 min
- ConvertersReading · 4 min
- Building URLs with url_forReading · 4 min
- HTTP methodsReading · 4 min
- Query strings with request.argsReading · 4 min
- Form data and headersReading · 4 min
- What a view can returnReading · 4 min
- RedirectsReading · 3 min
- Match URL rulesExercise · 14 min
Templates with Jinja11 lessons
- Rendering a templateReading · 4 min
- Showing values with {{ }}Reading · 4 min
- Loops and conditionsReading · 4 min
- FiltersReading · 4 min
- Your own filterReading · 4 min
- Autoescaping and |safeReading · 4 min
- A base templateReading · 4 min
- Extending a templateReading · 4 min
- Includes and macrosReading · 4 min
- Static filesReading · 4 min
- A tiny template rendererExercise · 14 min
Forms, redirects and flash messages9 lessons
- Forms with Flask-WTFReading · 5 min
- Showing a form in a templateReading · 4 min
- validate_on_submit()Reading · 5 min
- Showing errorsReading · 4 min
- CSRF protectionReading · 4 min
- Redirect after a POSTReading · 4 min
- Flash messagesReading · 4 min
- The secret keyReading · 3 min
- Check a notice formExercise · 12 min
Growing the app: blueprints and the factory8 lessons
- From one file to a packageReading · 4 min
- BlueprintsReading · 4 min
- Registering blueprintsReading · 4 min
- The application factoryReading · 5 min
- Extensions and init_appReading · 4 min
- ConfigurationReading · 5 min
- current_app and the app contextReading · 4 min
- An app factoryExercise · 12 min
A database with Flask-SQLAlchemy12 lessons
- Setting up Flask-SQLAlchemyReading · 4 min
- Defining a modelReading · 5 min
- RelationshipsReading · 5 min
- A command to create tablesReading · 5 min
- Adding rowsReading · 4 min
- Querying with select()Reading · 5 min
- The SQL behind a queryReading · 4 min
- One row, updates and deletesReading · 5 min
- Migrations with Flask-MigrateReading · 4 min
- Your first migrationReading · 4 min
- Changing a modelReading · 4 min
- Notices in SQLiteExercise · 12 min
User accounts with Flask-Login10 lessons
- How a login is rememberedReading · 4 min
- Storing passwords safelyReading · 4 min
- Setting up Flask-LoginReading · 5 min
- Signing upReading · 5 min
- Logging inReading · 5 min
- Logging outReading · 3 min
- Protecting pages with @login_requiredReading · 4 min
- Safe redirects with nextReading · 5 min
- current_userReading · 5 min
- A login_required decoratorExercise · 14 min
A JSON API and error handlers8 lessons
- Returning JSONReading · 4 min
- One notice, and JSON errorsReading · 4 min
- Receiving JSONReading · 5 min
- Checking API dataReading · 4 min
- CSRF and the APIReading · 4 min
- Error handlersReading · 5 min
- When the code crashes: 500Reading · 4 min
- JSON responsesExercise · 12 min
Testing with pytest9 lessons
- Why test a web appReading · 3 min
- Fixtures: app and clientReading · 5 min
- Your first testsReading · 4 min
- Running pytestReading · 4 min
- Testing forms and redirectsReading · 4 min
- Testing logins and permissionsReading · 5 min
- Testing the JSON APIReading · 4 min
- When a test failsReading · 4 min
- A tiny test runnerExercise · 12 min
Deploying, and Flask vs Django10 lessons
- Settings for productionReading · 4 min
- WSGI and wsgi.pyReading · 4 min
- GunicornReading · 4 min
- Waitress on WindowsReading · 4 min
- Going live: a checklistReading · 4 min
- Flask vs DjangoReading · 4 min
- When to pick whichReading · 4 min
- What you built, and what's nextReading · 3 min
- Settings from the environmentExercise · 12 min
- Final quizQuiz · 10 min
Reviews
No reviews yet.
Comments
Log in to join the conversation.
Loading comments...