Full Web Apps with HTML Pages using FastAPI Course

Course Summary

FastAPI has burst on to the Python web scene. In fact, the 2020 PSF developer survey shows FastAPI going from off the radar to the 3rd most popular and fastest growing framework for Python developers. People discovering FastAPI are thrilled with it's toolchain for building APIs. But they wonder if they will need to build a parallel app in Flask or Django for the HTML side of their site.

This course is here to show you that you do not need a second browser-oriented framework: FastAPI is a fantastic framework for HTML-oriented content and static content. That's what this course is all about. You'll learn to build full web apps with FastAPI, equivalent to what you can do with Flask or Django. And it's an amazing framework with even more features than those older, more established frameworks.

What students are saying

Really enjoying [Talk Python's] FastAPI courses so far. My favourite part is Michael's development style, where he gives you an "over the shoulder" perspective on how to segment and develop a project. Not only do you learn the content, you learn how to develop safely and efficiently. [...] Well worth your time and money.
-- Daniel T.

Source code and course GitHub repository

github.com/talkpython/web-applications-with-fastapi-course

What's this course about and how is it different?

There are not many courses out focusing on the FastAPI web framework. But even those that are around focus almost entirely on the API side of FastAPI. While that is useful and interesting, you'll need to answer the question of whether you need another web framework such as Flask or Django for the web browsers. The answer is no.

FastAPI is a truly modern framework that allows you to write web apps with dynamic HTML templates just as much as Flask. Throughout this course, you'll see how to use the various features of FastAPI along with a couple external packages to create wonderful Python web apps.

As part of the course, we well create a nearly complete clone of pypi.org in FastAPI. We'll learn how to use SQLAlchemy, HTML templates, static files, and even deploy our app to a Linux VM in the cloud.

Proceeds support the FastAPI project

Talk Python is a gold sponsor of the FastAPI project. By taking our course, you'll be helping support the improvement and sustainability of FastAPI itself.

What topics are covered

This course covers everything you need to know to develop, run, and deploy full web apps on top of FastAPI. Just some of the topics include:

  • Building a basic FastAPI application
  • Using server-side dynamic HTML templates such as Jinja2 and Chameleon
  • Centralizing look & feel as well as structural items with a layout HTML template
  • Serving static files from FastAPI (such as images and CSS files)
  • Using the view model design pattern to help with data exchange in FastAPI
  • Create HTML forms accepting user input and doing validation
  • Storing data in the SQLAlchemy ORM
  • Leveraging SQLAlchemy's new async/await capable API for scaling out
  • Deploy your FastAPI app to a Linux cloud VM

Who is this course for?

This course is for anyone who wants to use FastAPI as their primary web framework. You'll need basic Python programming experience and some familiarity with HTML and CSS.

Concepts backed by concise visuals

While exploring a topic interactively with demos and live code is very engaging, it can mean losing the forest for the trees. That's why when we hit a new topic, we stop and discuss it with concise and clear visuals.

Here's an example of understanding how FastAPI async and await support apply to scaling the concurrent requests for most web apps that spend their time waiting on external systems like databases.

Example: Concepts backed by concise visuals

This course is delivered in very high resolution

Example of 1440p high res video

This course is delivered in 1440p (4x the pixels as 720p). When you're watching the videos for this course, it will feel like you're sitting next to the instructor looking at their screen.

Every little detail, menu item, and icon is clear and crisp. Watch the introductory video at the top of this page to see an example.

Follow along with subtitles and transcripts

Each course comes with subtitles and full transcripts. The transcripts are available as a separate searchable page for each lecture. They also are available in course-wide search results to help you find just the right lecture.

Each course has subtitles available in the video player.

Who am I? Why should you take my course?

Who is Michael Kennedy?

My name is Michael, nice to meet you. ;) There are a couple of reasons I'm especially qualified to teach you Python.

 1. I'm the host of the #1 podcast on Python called Talk Python To Me. Over there, I've interviewed many of the leaders and creators in the Python community. I bring that perspective to all the courses I create.

 2. I've been a professional software trainer for over 10 years. I have taught literally thousands of professional developers in hundreds of courses throughout the world.

 3. Students have loved my courses. Here are just a few quotes from past students of mine.

"Michael is super knowledgeable, loves his craft, and he conveys it all well. I would highly recommend his training class anytime." - Robert F.
"Michael is simply an outstanding instructor." - Kevin R.
"Michael was an encyclopedia for the deep inner workings of Python. Very impressive." - Neal L.

Free office hours keep you from getting stuck

One of the challenges of self-paced online learning is getting stuck. It can be hard to get the help you need to get unstuck.

That's why at Talk Python Training, we offer live, online office hours. You drop in and join a group of fellow students to chat about your course progress and see solutions via screen sharing.

Just visit your account page to see the upcoming office hour schedule.

The time to act is now

FastAPI is an exciting new web framework. Having deep knowledge and fluency in it opens the door to career advancement and better tools and technologies on your current project. These have powerful knock-on effects. For example, FastAPI's great support of async and await mean you have new techniciques for working with databases and external APIs. So join this course and see how FastAPI can be used to build general web apps, not just APIs.

Course Outline: Chapters and Lectures

Welcome to the course
12:47
APIs or web apps?
3:01
FastAPI compared to other frameworks
3:01
Big ideas covered in the course
3:17
Student expectations
0:58
What are we going to build?
1:14
Your instructor, Michael Kennedy
0:39
Get the full story on FastAPI
0:37
Setup and following along
7:24
Do you have Python?
3:09
Our code editor
2:31
PyCharm Pro for Free
0:30
Git the source code
1:14
Creating our first FastAPI *site*
13:36
Chapter introduction
1:43
Creating the Python project
4:09
A basic FastAPI app
5:13
Ready for running in production
2:31
Dynamic HTML templates
53:10
Template introduction
1:13
Rendering basic HTML
4:07
Template languages options
1:30
Template languages: A comparison
6:22
Rendering basic HTML template
6:28
Organizing view methods
11:16
Concept: Shared layout
2:24
Creating the shared layout HTML file
6:14
Static files
3:53
Bringing in the real layout
4:00
Bringing in the real home page
5:43
View models and services
38:37
View models and Services Introduced
1:44
View model pattern visualized
3:41
Adding a view model to the home/index view
8:44
Services for view models
3:41
A few more view models left to create
3:08
Survey the package details page
1:08
Adding HTML for package details
3:44
Create the package and release classes
7:57
Benefits of using view models everywhere
4:50
Users and HTML forms
39:47
Intro to chapter
0:49
A basic user class
1:46
GET/POST/Redirect pattern in FastAPI
3:02
GET/POST/Redirect for registration
5:36
Receiving registration data with view model
7:09
Redirecting after registering
3:39
Client-side validation
3:56
User sessions via cookies
5:50
User sessions via cookies, safer version
3:26
Logging out
1:23
Login, like registration, so we'll go fast
3:11
Storing data with SQLAlchemy
1:01:13
Intro to SQLAlchemy chapter
2:14
Need to learn SQLAlchemy? See the appendix
2:05
Which version of SQLAlchemy
4:06
SQLAlchemy session/unit of work setup
9:19
Making the User class a SQLAlchemy class
7:19
Package and releases SQLAlchemy classes
5:29
Populating the database with PyPI data
4:49
Home page queries
7:11
Package details queries
2:53
Latest release for a package
1:34
User queries
7:28
Storing the password securely
6:46
async databases with SQLAlchemy
39:07
Intro to chapter
1:31
Beta software: See the revisions doc
1:45
Async for scalability - sync version
4:52
Async for scalability - async version
1:42
Updating the db_session for async
3:43
User service async queries
7:46
Find user by id and email, async
4:24
Async create account
2:03
Async login user
3:42
The remaining database queries
7:39
Deploying FastAPI on Linux with gunicorn and nginx
41:39
Deployment introduction
2:06
Beware of the docs
4:29
Surveying some hosting options
5:49
Create a cloud server
3:51
Connecting to and patching our server
2:04
Server topology with Gunicorn
3:18
Adding ohmyzsh
1:10
Preparing to run FastAPI on Ubuntu
3:37
Getting the source code from GitHub
4:16
venv forever
1:12
Gunicorn as Systemd unit
4:13
Installing and running nginx
3:29
Adding SSL for HTTPS on our API
2:05
Course conclusion and review
16:21
Conclusion
1:13
Our first site, a minimal FastAPI website
2:23
Template languages
1:59
View model pattern
2:17
GET/POST/Redirect pattern
1:55
SQLAlchemy models
1:59
async and await
2:10
Deployment
2:00
Thanks and goodbye
0:25
Appendix: Modeling data with SQLAlchemy classes
54:50
Introducing SQLAlchemy
4:07
Who uses SQLAlchemy?
1:35
Architecture
2:14
The database model
3:10
Modeling packages
8:31
SQLAlchemy model base class
1:51
Connecting to our 'database'
6:01
Creating tables
6:26
Indexes
5:00
The rest of the tables
4:24
Relationships
7:16
Concepts: Modeling
4:15
Appendix: Using SQLAlchemy
52:56
Creating the basic insert script
2:18
Connecting to the database (again)
1:36
Setting package values
1:33
Saving the package to the db
3:36
Running the inserts
2:34
Adding type hints to the session factory
1:20
Inserting real PyPI data
5:09
Concept: Unit of work
2:22
Querying data: Home page
5:55
Querying data: Latest releases
9:03
Working with package details
9:18
Concept: Querying data
4:03
Concept: Ordering data
0:44
Concept: Database updates
0:49
Concept: Relationships
1:59
Concept: Inserting data
0:37
Buy for $49 + tax Bundle and save 85% Team Gift

Questions? Send us an email: contact@talkpython.fm

Talk Python's Mastodon Michael Kennedy's Mastodon