How to Run Background Tasks in FastAPI (2 Ways)
In a FastAPI web application, you can do some work in the background without blocking the main thread or the response to the client. This is useful for…
How to Implement Redirects in FastAPI (2 Ways)
Redirect means sending users from one URL to another, usually after performing some action or checking some condition (such as authentication, payment, etc.). This concise, example-based article will…
How to Return PDF Files in FastAPI (3 Examples)
This succinct, straight-to-the-point article will walk you through a couple of different ways to return PDF files in FastAPI. In the upcoming examples, we’ll use this sample PDF…
How to Run FastAPI on a Custom Port
To run a FastAPI application on a custom port, you need to specify the port number when you start your application. The port number is an integer between…
FastAPI: How to Change the Response Status Code
FastAPI, as its name implies, is a fast, modern, and high-performance web framework for building backend APIs with Python. The response status code is a three-digit number that…
How to Model Reponses in FastAPI (3 Examples)
The Fundamentals FastAPI is a fast-growing Python web framework that can help you build high-performance backend projects. One of the features of the web framework is that it…
FastAPI: How to Create a Custom 404 (Not Found) Route
404 is an HTTP status code that indicates that a server couldn’t find the resource requested by a client (such as a web browser or API client). FastAPI…
FastAPI AttributeError: ‘dict’ object has no attribute ‘encode’
This concise, straight-to-the-point article will walk you through a couple of different solutions to fix a common error you might encounter when working with FastAPI. The Problem Here…
2 Ways to Implement Pagination in FastAPI
Introduction Pagination is a process of dividing a large amount of data into smaller chunks. It is important because it can improve the performance, usability, and security of…
FastAPI: Render HTML Templates with Dynamic Content
Overview FastAPI is often used to develop backend APIs. However, you can also use this web framework to render HTML templates and create websites with the help of…