FastAPI in a nutshell
In Chapter 1, Web Development and the FARM Stack, it was mentioned why FastAPI is the preferred REST framework in the FARM stack. What sets FastAPI apart is its coding speed and the resulting clean code, with which you can spot bugs quickly and early. The author of the framework himself, Sebastian Ramirez, often modestly emphasizes that FastAPI is just a mix of Starlette and Pydantic, while heavily relying on modern Python features, especially type hinting.
Before diving into an example and building a FastAPI app, it is useful to quickly go over the frameworks that FastAPI is based on.
Starlette
Starlette is an ASGI framework known for its top performance and numerous features, which are also available in FastAPI. These include WebSocket support, events on startup and shutdown, session and cookie support, background tasks, middleware implementations, and templates. While you will not be coding directly in Starlette, it is important to know how FastAPI...