FastAPI Cookbook: Develop high-performance APIs and web applications with Python
معرفی کتاب «FastAPI Cookbook: Develop high-performance APIs and web applications with Python» نوشتهٔ Antonio Ferraro, Giunio de Luca، منتشرشده توسط نشر Packt Publishing در سال 2024. این کتاب در 5 صفحه، فرمت pdf، زبان انگلیسی ارائه شده است. «FastAPI Cookbook: Develop high-performance APIs and web applications with Python» در دستهٔ بدون دستهبندی قرار دارد.
Enhance your web development skills, from setting up your environment and advanced integrations to building robust, high-traffic web applications with practical, scalable solutions Key Features • Explore FastAPI in depth, from basic setup to advanced features such as custom middleware and WebSockets • Discover practical strategies to optimize app performance and handle high traffic • Implement SQL and NoSQL integration techniques for versatile data management in FastAPI applications Book Description FastAPI is a cutting-edge Python framework that is revolutionizing the way web apps and APIs are built. Known for its speed, simplicity, and scalability, FastAPI empowers developers to create high-performing applications with ease. This book will help you leverage FastAPI’s immense potential to handle high-traffic scenarios and integrate seamlessly with modern Python tools. The book begins by familiarizing you with the basics of setting up and configuring your FastAPI environment before moving to the intricacies of building RESTful APIs, managing data with SQL and NoSQL databases, and handling authentication and authorization. Next, you'll focus on advanced topics such as custom middleware, WebSocket communication, and integration with various Python libraries. Each chapter is meticulously crafted with practical recipes, progressing from foundational concepts to advanced features and best practices. The concluding chapters show you how to optimize performance, implement rate limiting, and execute background tasks, empowering you to become a proficient FastAPI developer. By the end of this book, you'll have gained the skills you need to migrate existing apps to FastAPI, and be equipped to tackle any challenge in the modern web development landscape, ensuring your apps are not only functional, but also efficient, secure, and scalable. Who is this book for? This book is for Python developers looking to enhance their skills to build scalable, high-performance web apps using FastAPI. Professionals seeking practical guidance to create APIs and web apps that can handle significant traffic and scale as needed will also find this book helpful by learning from both foundational insights and advanced techniques. The book is also designed for anyone familiar with RESTful APIs, HTTP protocols, and database systems, as well as developers looking to migrate existing applications to FastAPI or explore its advanced features. What you will learn • Explore advanced FastAPI functionalities such as dependency injection, custom middleware, and WebSockets • Discover various types of data storage for powerful app functionality with SQL and NoSQL • Implement testing and debugging practices for clean, robust code • Integrate authentication and authorization mechanisms to secure web apps • Acquire skills to seamlessly migrate existing applications to FastAPI • Write unit and integration tests, ensuring reliability and security for your apps • Deploy your FastAPI apps to production environments for real-world use Cover Title Page Copyright and Credits Dedication Foreword Contributors Table of Contents Preface Chapter 1: First Steps with FastAPI Technical requirements Setting up your development environment Getting ready How to do it... Creating a new FastAPI project Getting ready How to do it... There’s more... See also Understanding FastAPI basics How to do it... See also Defining your first API endpoint Getting ready How to do it... How it works... Working with path and query parameters Getting ready How to do it... How it works... See also Defining and using request and response models Getting ready How to do it... See also Handling errors and exceptions How to do it... There’s more... See also Chapter 2: Working with Data Technical requirements Setting up SQL databases Getting ready How to do it... Establishing a database connection See also Understanding CRUD operations with SQLAlchemy Getting ready How to do it... See also Integrating MongoDB for NoSQL data storage Getting ready How to do it... See also Working with data validation and serialization Getting ready How to do it... Serialization and deserialization concepts Advanced validation techniques See also Working with file uploads and downloads Getting ready How to do it... Implementing file uploads Managing file downloads and storage See also Handling asynchronous data operations Getting ready How to do it... There’s more... See also Securing sensitive data and best practices Getting ready How to do it... There’s more... Chapter 3: Building RESTful APIs with FastAPI Technical requirements Creating CRUD operations How to do it... How it works... Creating RESTful Endpoints Getting ready... How to do it... Testing your RESTful API Getting ready... How to do it... See also Handling complex queries and filtering Getting ready... How to do it... Versioning your API Getting ready... How to do it... There’s more... See also Securing your API with OAuth2 Getting ready... How to do it... There’s more... See also Documenting your API with Swagger and Redoc Getting ready... How to do it... See also Chapter 4: Authentication and Authorization Technical requirements Setting up user registration Getting ready How to do it... How it works... See also Working with OAuth2 and JWT for authentication Getting ready How to do it... How it works... See also Setting up RBAC Getting ready How to do it... There’s more... Using third-party authentication Getting ready How to do it... How it works... See also Implementing MFA Getting ready How to do it... See also Handling API key authentication Getting ready How to do it... There’s more... Handling session cookies and logout functionality Getting ready How to do it... There’s more... See also Chapter 5: Testing and Debugging FastAPI Applications Technical requirements Setting up testing environments Getting ready How to do it... See also Writing and running unit tests Getting ready How to do it... See also Testing API Endpoints Getting ready How to do it... See also Running tests techniques Getting ready How to do it... Check test coverage See also Handling logging messages Getting ready How to do it... There’s more See also Debugging techniques Getting ready How to do it... Debugging with PDB Debugging with VS Code Debugging with PyCharm See also Performance testing for high traffic applications Getting ready How to do it... See also Chapter 6: Integrating FastAPI with SQL Databases Technical requirements Setting up SQLAlchemy Getting ready How to do it... How it works... See also Implementing CRUD operations Getting ready How to do it... How it works... Working with migrations Getting ready How to do it... How it works... See also Handling relationships in SQL databases Getting ready How to do it... See also Optimizing SQL queries for performance Getting ready How to do it... There’s more... Securing sensitive data in SQL databases Getting ready How to do it... See also Handling transactions and concurrency Getting ready How to do it... There’s more... See also Chapter 7: Integrating FastAPI with NoSQL Databases Technical requirements Setting up MongoDB with FastAPI Getting ready How to do it... See also CRUD operations in MongoDB Getting ready How to do it... See also Handling relationships in NoSQL databases Getting ready How to do it... See also Working with indexes in MongoDB Getting ready How to do it... How it works... There’s more... See also Exposing sensitive data from NoSQL databases Getting ready How to do it... There’s more... See also Integrating FastAPI with Elasticsearch Getting ready How to do it... See also Using Redis for caching in FastAPI Getting ready How to do it... There’s more... See also Chapter 8: Advanced Features and Best Practices Technical requirements Implementing dependency injection Getting ready How to do it... How it works... There’s more... See also Creating custom middleware Getting ready... How to do it... How it works... See also Internationalization and localization Getting ready How to do it... See also Optimizing application performance Getting ready How to do it... There’s more... See also Implementing rate limiting Getting ready How to do it... There's more... See also Implementing background tasks Getting ready How to do it... How it works... See also Chapter 9: Working with WebSocket Technical requirements Setting up WebSockets in FastAPI Getting ready How to do it... How it works... See also Sending and receiving messages over WebSockets Getting ready How to do it... See also Handling WebSocket connections and disconnections Getting ready How to do it... Handling WebSocket errors and exceptions Getting ready How to do it... See also Implementing chat functionality with WebSockets Getting ready How to do it... How it works... See also Optimizing WebSocket performance Getting ready How to do it... There’s more... See also Securing WebSocket connections with OAuth2 Getting ready How to do it... See also Chapter 10: Integrating FastAPI with other Python Libraries Technical requirements Integrating FastAPI with gRPC Getting ready How to do it... There’s more... See also Connecting FastAPI with GraphQL Getting ready How to do it... See also Using ML models with Joblib Getting ready How to do it... See also Integrating FastAPI with Cohere Getting ready How to do it... See also Integrating FastAPI with LangChain Getting ready How to do it... See also Chapter 11: Middleware and Webhooks Technical requirements Creating custom ASGI middleware Getting ready How to do it... How it works... There’s more... See also Developing middleware for request modification Getting ready How to do it... See also Developing middleware for response modification Getting ready How to do it... See also Handling CORS with middleware Getting ready How to do it... See also Restricting incoming requests from hosts Getting ready How to do it... See also Implementing webhooks Getting ready How to do it... How it works... There’s more... See also Chapter 12: Deploying and Managing FastAPI Applications Technical requirements Running the server with the FastAPI CLI Getting ready How to do it... There’s more... See also Enabling HTTPS on FastAPI applications Getting ready How to do it... There’s more... See also Running FastAPI applications in Docker containers Getting ready How to do it... See also Running the server across multiple workers Getting ready How to do it... There’s more... See also Deploying your FastAPI application on the cloud Getting started How to do it... There’s more... See also Shipping FastAPI applications with Hatch Getting ready How to do it... There’s more... See also Index Other Books You May Enjoy
دانلود کتاب FastAPI Cookbook: Develop high-performance APIs and web applications with Python