Автор: Malhar Lathkar
Издательство: Apress
Год: 2023
Страниц: 321
Язык: английский
Формат: pdf, epub
Размер: 12.8 MB
Build APIs and web apps based on Asynchronous Server Gateway Interface (ASGI). This book provides a comprehensive explanation of using Pydantic models to construct the request/response objects in a FASTAPI path operation.
You’ll start by reviewing type hints in Python and the asynchronous processing concepts. One of the highlights of FastAPI is its auto generation of API docs. Pydantic library is the main pillar on top of which FastAPI is built. You’ll see that ASGI has a far better performance compared to most of the other popular Python frameworks as they implement Web server Gateway Interface (WSGI), which is synchronous in nature and hence having slower response time.
This book thoroughly explains how FastAPI interacts asynchronously with relational as well as NOSQL databases. Modern web apps use template engines to interact with the front-end. In this book, you will learn to use jinja2 templates and static assets. Swagger UI and OpenAPI standards are also covered in detail. Finally, different options of deployment of FastAPI app have been explored in this book. This book uses practical examples to empower you to build high performance APIs
This book comprises ten chapters:
Chapter 1: To begin with, Python’s type hinting and its handling of asynchronous process are the two aspects introduced. FastAPI is built on top of Starlette and Pydantic. In this chapter, the reader is introduced to these two libraries.
Chapter 2: FastAPI follows OpenAPI standards and integrates seamlessly with Swagger UI. In this chapter, the reader will learn how FastAPI is able to autogenerate the documentation for the API endpoints.
Chapter 3: This chapter deals with Pydantic’s BaseModel and how it populates the body of an HTTP request.
Chapter 4: Although FastAPI is primarily a tool for API development, it can also be used to build web applications that render web pages and serve static assets. This chapter covers how to use jinja2 templates and include static files.
Chapter 5: This chapter explains how the FastAPI application inserts cookies and headers in its response and how it is able to retrieve them.
Chapter 6: This chapter provides a comprehensive explanation of using SQL and NoSQL databases as the back end for a FastAPI application.
Chapter 7: This chapter is the beginning of the advanced part of this book. It introduces APIRouters with which bigger applications can be modularly constructed.
Chapter 8: Apart from REST, FastAPI supports WebSocket and GraphQL protocols. This chapter describes how to design apps that implement WebSocket and GraphQL.
Chapter 9: This chapter explains how the reader can secure the API with different provisions in FastAPI. The reader is also introduced to FastAPI’s testing functionality.
Chapter 10: Deploying your API for public availability is very important. This chapter discusses different deployment alternatives.
What You'll Learn:
Develop robust and high-performance web apps
Deploy the FastAPI app for public availability using cloud services such as Deta and Docker container
Understand the important building blocks of a web app such as form handling, templating and database interaction
Who This Book Is For:
Aspiring and the experienced Python developers looking to leverage the flexibility of Python and the powerful features introduced in Modern Python. Computer science Engineering students at graduate and postgraduate level will also benefit immensely from the practical approach adapted in the book.
Скачать High-Performance Web Apps with FastAPI: The Asynchronous Web Framework Based on Modern Python