Mô tả

With FastAPI you can build complete, high-performance APIs in days, and adding new features is blazing-fast. That's why FastAPI has become so popular in recent years.

In this course, I'll show you how to go from a blank slate to a complete, finished FastAPI application.


The project

We'll build social media API with user authentication, email sending, and file upload. Users will be able to register and log in using Bearer (JWT) tokens. They will be able to create posts, leave comments, and like existing posts.

We'll use Pydantic for data validation and encode/databases as our database connectivity library.


Advanced knowledge

Use background tasks in FastAPI to improve performance when running slow code, such as when sending emails (covered in the course) or when making slow requests to third party APIs (also covered).

Throughout the course we use an async database library, again to maximise performance, which is nonetheless straightforward to use. You'll learn about the different types of data relationships and how to model them, including many-to-many relationships.

You'll learn how to handle file uploads and what to do with the uploaded files, so you don't run out of server space.


Complete API testing

Finally, 100% of the code in this course has tests. You'll use pytest extensively to write integration and unit tests for the API. You'll learn about pytest fixtures, parametrization, and testing conventions.

Part of real-world development means logging! There's a lot of logging knowledge in this course, including how to set up the logging module properly, when to make logging calls, and where to store logs when your application is deployed.


Deployments

Of course, I'll show you how to deploy your FastAPI app using popular service Render.  You can deploy your FastAPI app for free, but I'll also show you some paid options for improved performance.

We'll also look at application management, error handling with Sentry, and CI/CD with GitHub Actions.


If you use or want to use FastAPI, this course contains everything you need to develop complete, real-world APIs.


Let's get started. I'll see you on the inside!

Bạn sẽ học được gì

Gain broad experience with FastAPI

Understand how to test FastAPI apps using Pytest with 100% test coverage

Become a master of logging with the built-in logging module

Add user authentication with password hashing and Bearer tokens

Use an async SQL database and model one-to-many and many-to-many relationships

Send user emails when they register without a performance hit using background tasks

Handle file uploads and store them in a third-party service

Deploy your FastAPI apps to the cloud

Yêu cầu

  • Some prior programming experience in any programming language.
  • All software used in the course is provided, and completely free
  • Complete beginners may wish to take a beginner Python course first, and then transition to this course afterwards

Nội dung khoá học

11 sections

Course Introduction

7 lectures
Community
00:24
Instructions - Join the Community
01:39
Welcome to this course!
02:59
Platform features and note-taking
00:56
You can do it!
01:01
What is an API?
09:44
What is REST?
09:23

Working with FastAPI

7 lectures
Introduction to this section
02:52
Your First FastAPI App
03:58
Initial App Setup
07:49
Linting, formatting and sorting imports
05:52
Our social media API: adding posts
10:57
Splitting our API into files with APIRouter
02:21
Adding comments to the social medical API
11:07

Introduction to pytest

6 lectures
Introduction to the pytest section
00:42
The basics of pytest
06:26
Getting started with FastAPI tests
07:34
Creating posts in our tests
04:30
Adding tests for posts
09:16
Adding comments tests
08:00

Working with async databases

9 lectures
Introduction to working with databases
01:19
Installing requirements for async databases in FastAPI
01:57
Creating a config file using Pydantic
03:25
Different configurations per environment in
06:15
Config caching and how to get the config object
04:26
Async database setup with FastAPI
07:38
Database connection with lifespan events in FastAPI
04:46
Run your FastAPI test in 'test' mode
02:19
Using a database in our FastAPI router
16:07

Logging in FastAPI applications

14 lectures
Introduction to logging
01:00
Python logging: loggers, handlers, and formatters
15:59
Logger hierarchies and __name__
08:09
Adding Logging Configuration for FastAPI Applications
10:54
How to configure multiple loggers in the logging module
03:37
Adding File Handlers for Saving Logs
07:43
Add logging to your FastAPI endpoints
06:53
Python logging: filters and custom filters
04:54
Logging HTTPExceptions with an Exception Handler
02:35
Identifying logs from the same request: Correlation ID
07:27
Adding JSON-formatted log files
02:34
Obfuscating email addresses in logs using a custom filter
09:14
Adding Logtail for Cloud Logging in FastAPI
03:43
Enabling Logtail in only in production
01:19

User authentication with FastAPI

12 lectures
Introduction to user authentication
01:01
Installing requirements and, what are JWTs?
07:21
Adding a users table and retrieving users by email
03:21
Adding user registration and tests
11:12
Adding tests for the user registration endpoint
03:14
How to hash passwords with passlib
06:17
Generate the access token
13:22
Retrieve the current user with their token
06:35
Use the current user in the API router
13:59
Dependency injection: getting the user
03:48
Adding user relationships to other tables
03:02
(Optional) OAuth Password Bearer and Swagger Auth
04:51

Many-to-many relationships

5 lectures
Introduction to many-to many
00:24
Adding a table for post likes
01:11
Adding an API route to like posts
07:21
Extracting reusable queries with SQLAlchemy
08:16
Query string arguments and data sorting with Enum
16:51

User email confirmation

8 lectures
Creating the confirmation token
07:01
Decoding the confirmation token
14:33
Adding a user confirmation endpoint
10:25
Requiring user confirmation for authenticated requests
04:05
Mailgun set-up and configuration
02:44
Sending emails and testing with Python
15:47
Sending a confirmation email on registration
04:48
Sending emails with background tasks
05:59

File Uploads with FastAPI

5 lectures
Account setup for Backblaze B2
01:18
Our configuration for Backblaze B2
01:29
Internal library for Backblaze B2
09:57
Writing our file upload endpoint
09:24
Writing tests for file upload
18:22

Background Tasks for Image Generation

4 lectures
Model and database changes for image generation
02:44
Configuration for DeepAI, our third party service
03:46
Generating images using background tasks
20:41
Executing image generation in our FastAPI endpoint
07:12

FastAPI Deployments and Application Management

5 lectures
Updating our project to Pydantic v2
06:29
Deploy a FastAPI app to Render
06:09
Add a free PostgreSQL database to your FastAPI app
09:15
Error management with Sentry for FastAPI apps
07:58
Continuous Integration with GitHub Actions for Python apps
08:19

Đánh giá của học viên

Chưa có đánh giá
Course Rating
5
0%
4
0%
3
0%
2
0%
1
0%

Bình luận khách hàng

Viết Bình Luận

Bạn đánh giá khoá học này thế nào?

image

Đăng ký get khoá học Udemy - Unica - Gitiho giá chỉ 50k!

Get khoá học giá rẻ ngay trước khi bị fix.