#246: Helpful Tricks for FastAPI
Before we end this series on FastAPI, I am going to take you for another round to show you a few helpful little tricks that can improve your FastAPI experience.
Before we end this series on FastAPI, I am going to take you for another round to show you a few helpful little tricks that can improve your FastAPI experience.
With our authentication system in place, it is time to put our to-do application into production. For this post I start with a basic Docker container and when that runs, we can add more parts to create a production-ready setup.
A few weeks ago, we explored two approaches to add authentication to our FastAPI applications. In this post we go a different way and integrate a package that does the heavy lifting for us. I decided to go with FastAPI Users, even when it takes a big step to integrate it.
A simple way to protect our API is to limit the number of calls a client can make in a given timespan. For FastAPI, we can use the SlowApi package to prevent our application from being flooded with requests.
Last week we created a breaking change when we added the new filter syntax. With API versioning we try to prevent that and make the breaking changes in a different version of an endpoint. There are many ideas on how to version endpoints the correct way, but so far there is no standard that we can follow. In this post we explore 3 approaches to learn the options we have in FastAPI.
Our filter for retrieving the tasks we are interested in still fetches all data from the database before applying the actual filtering. It is time to fix that and use a more flexible solution that works with the asynchronous SQLAlchemy that we introduced in the last post.
Last week we got pytest to run asynchronous test methods. That was the preparation step for this post where we switch to asynchronous SQLAlchemy for our to-do application. As it turns out, switching to asynchronous methods for SQLAlchemy takes a lot of work. Let us get through the different changes we need to make.
We already created a shared layout for the web interface of our API and fixed the problem with the static resources. Now we can create a dashboard that shows us some important numbers about our application.
When we start serving HTML files with our FastAPI application, we need a way to send images, CSS- and JavaScript files without creating an endpoint for each file. Let us solve this problem with a static route.
Last week we added Alembic to our to-do app to be ready for upcoming changes to the tables. In this post we extend our FastAPI application, but in an unexpected direction: we add a web interface. Let us find out how we can do that.