Tag

FastAPI

0 views collected around this technical thread.

Code Mala Tang
Code Mala Tang
Jun 12, 2025 · Backend Development

Essential FastAPI Middleware Guide: Boost Security, Performance, and Functionality

This article explains how FastAPI middleware sits between incoming requests and outgoing responses, detailing built‑in and third‑party middleware such as CORS, GZip, HTTPS redirect, session, trusted host, error handling, rate limiting, authentication, custom headers, logging, timeout, trailing‑slash handling, IP whitelisting, proxy headers, CSRF protection, context management and global state, each with usage scenarios and code examples.

BackendFastAPIPython
0 likes · 20 min read
Essential FastAPI Middleware Guide: Boost Security, Performance, and Functionality
Code Mala Tang
Code Mala Tang
Jun 10, 2025 · Backend Development

Boost Your FastAPI API Performance with Redis Caching: A Step‑by‑Step Guide

This tutorial explains how to integrate Redis caching into a FastAPI application, covering installation, connection handling, cache expiration, testing, cache clearing, and best‑practice considerations to dramatically improve API response times and scalability.

BackendCachingFastAPI
0 likes · 9 min read
Boost Your FastAPI API Performance with Redis Caching: A Step‑by‑Step Guide
Code Mala Tang
Code Mala Tang
Jun 9, 2025 · Backend Development

Build High‑Performance APIs with FastAPI and Swagger: A Hands‑On Guide

Learn how to create fast, modern Python APIs using FastAPI, automatically generate interactive Swagger documentation, and enhance your endpoints with validation, metadata, and a full-featured to‑do list project, all illustrated with clear code examples and step‑by‑step deployment instructions.

API DevelopmentFastAPIOpenAPI
0 likes · 10 min read
Build High‑Performance APIs with FastAPI and Swagger: A Hands‑On Guide
Code Mala Tang
Code Mala Tang
Jun 2, 2025 · Backend Development

Unlocking FastAPI: A Deep Dive into Starlette, ASGI, and Middleware Architecture

This article explains how FastAPI builds on Starlette, covering the ASGI protocol, Starlette's initialization, middleware design—including ExceptionMiddleware and user-defined middleware—and routing mechanisms, while providing concrete code examples and performance insights for backend developers.

ASGIFastAPIRouting
0 likes · 22 min read
Unlocking FastAPI: A Deep Dive into Starlette, ASGI, and Middleware Architecture
Code Mala Tang
Code Mala Tang
Jun 2, 2025 · Backend Development

Generate Professional PDFs Directly from FastAPI with xhtml2pdf

Learn how to quickly create downloadable, professionally styled PDF invoices using FastAPI and the xhtml2pdf library, covering prerequisites, FastAPI setup, HTML template design, PDF rendering, and server launch, plus tips for dynamic data, alternative tools, and security considerations.

FastAPIPDF generationPython
0 likes · 6 min read
Generate Professional PDFs Directly from FastAPI with xhtml2pdf
Code Mala Tang
Code Mala Tang
May 31, 2025 · Backend Development

How to Overcome FastAPI’s CPU‑Bound Bottlenecks: Practical Parallelism Strategies

This article explains why FastAPI struggles with CPU‑intensive tasks due to Python’s Global Interpreter Lock, describes the types of workloads affected, and provides concrete solutions such as background task queues, microservices, ProcessPoolExecutor, and C/C++ extensions to keep APIs responsive and scalable.

CPU-boundConcurrencyFastAPI
0 likes · 8 min read
How to Overcome FastAPI’s CPU‑Bound Bottlenecks: Practical Parallelism Strategies
Code Mala Tang
Code Mala Tang
May 29, 2025 · Backend Development

From Hard‑Coded Secrets to YAML‑Powered Configs: A Backend Configuration Journey

This article walks through a step‑by‑step evolution of backend configuration management—from hard‑coded constants to modular config files, environment‑specific .env files, Pydantic‑validated models, and finally YAML‑based settings—demonstrating how to build a clean, secure, and scalable setup for FastAPI applications.

FastAPIPydanticPython
0 likes · 17 min read
From Hard‑Coded Secrets to YAML‑Powered Configs: A Backend Configuration Journey
Code Mala Tang
Code Mala Tang
May 27, 2025 · Backend Development

Mastering Database Connections in FastAPI: Best Practices and Code Samples

Learn how to efficiently configure and manage database connections in FastAPI, covering synchronous and asynchronous setups, dependency injection, session handling, and testing strategies, to prevent leaks, boost performance, and ensure scalable, reliable applications.

AsyncConnection ManagementFastAPI
0 likes · 8 min read
Mastering Database Connections in FastAPI: Best Practices and Code Samples
DeWu Technology
DeWu Technology
May 26, 2025 · Backend Development

Integrating FastAPI with MCP for AI‑Driven Test Data Generation

This article explains how to transform a FastAPI service into an MCP‑compatible tool, enabling AI agents to automatically orchestrate multi‑step test data creation, covering installation, project structure, code annotations, tool configuration, and practical integration with the Cursor platform.

AIBackendFastAPI
0 likes · 19 min read
Integrating FastAPI with MCP for AI‑Driven Test Data Generation
Code Mala Tang
Code Mala Tang
May 24, 2025 · Backend Development

7 Essential FastAPI Middleware to Boost Performance, Security, and Maintainability

This guide explores seven practical FastAPI middleware components—covering CORS, GZip compression, request logging, trusted hosts, HTTPS redirection, custom exception handling, and rate limiting—to help developers build faster, safer, and more maintainable APIs.

FastAPIPythonSecurity
0 likes · 7 min read
7 Essential FastAPI Middleware to Boost Performance, Security, and Maintainability
Code Mala Tang
Code Mala Tang
May 21, 2025 · Backend Development

Master FastAPI Responses: JSON, HTML, Files, Streaming & Custom Classes

Learn how FastAPI handles various response types—including default JSON, custom status codes and headers, HTMLResponse, FileResponse, StreamingResponse, and user‑defined response classes—while covering best practices, common pitfalls, and code examples for building robust APIs.

API responsesBackendFastAPI
0 likes · 8 min read
Master FastAPI Responses: JSON, HTML, Files, Streaming & Custom Classes
Code Mala Tang
Code Mala Tang
May 20, 2025 · Backend Development

Master FastAPI’s Application Lifecycle: From Startup to Shutdown

This guide explains FastAPI’s full application lifecycle—including startup initialization, middleware handling, request processing steps, background tasks, and graceful shutdown—so developers can design, debug, and deploy robust asynchronous APIs efficiently.

APIApplication LifecycleAsync
0 likes · 7 min read
Master FastAPI’s Application Lifecycle: From Startup to Shutdown
Code Mala Tang
Code Mala Tang
May 19, 2025 · Backend Development

How to Implement Server‑Sent Events (SSE) in FastAPI for Real‑Time Apps

Server‑Sent Events (SSE) provide a simple, one‑way server push mechanism over HTTP, ideal for real‑time updates such as dashboards, notifications, and data streams; this guide explains SSE fundamentals, compares alternatives, and walks through integrating SSE into FastAPI using the sse‑starlette library with full code examples.

FastAPIPythonSSE
0 likes · 9 min read
How to Implement Server‑Sent Events (SSE) in FastAPI for Real‑Time Apps
php中文网 Courses
php中文网 Courses
May 19, 2025 · Backend Development

Comprehensive Guide to Python Web Development: Frameworks, Ecosystem, and Practical Cases

This article provides a thorough overview of Python's role in web development, covering core components, major frameworks like Django, Flask, and FastAPI, ecosystem tools, real-world case studies, learning paths, and future trends for building modern backend applications.

BackendDjangoFastAPI
0 likes · 7 min read
Comprehensive Guide to Python Web Development: Frameworks, Ecosystem, and Practical Cases
Code Mala Tang
Code Mala Tang
May 16, 2025 · Backend Development

How to Run Non-Blocking Background Tasks in FastAPI with BackgroundTasks

FastAPI’s BackgroundTasks feature lets you register functions that run after a response is sent, enabling non‑blocking operations such as sending emails, logging, or cleaning resources, with simple code examples, parameter details, and insights into its Starlette‑based implementation and limitations.

BackgroundTasksFastAPIPython
0 likes · 6 min read
How to Run Non-Blocking Background Tasks in FastAPI with BackgroundTasks
Code Mala Tang
Code Mala Tang
May 13, 2025 · Backend Development

Master FastAPI Testing: Unit & Integration Tests with Pytest & HTTPX

This guide walks you through setting up a FastAPI testing environment, creating a project structure, writing both unit and integration tests using pytest, httpx, and FastAPI's TestClient, and running the tests to ensure reliable, maintainable applications.

BackendFastAPIhttpx
0 likes · 6 min read
Master FastAPI Testing: Unit & Integration Tests with Pytest & HTTPX
Code Mala Tang
Code Mala Tang
May 12, 2025 · Backend Development

How to Build a FastAPI Service with RabbitMQ Consumer & Publisher

This guide walks through creating a FastAPI application that both publishes and consumes messages via RabbitMQ, detailing the setup of a Pika client, asynchronous consumer, message handling, API routes, and deployment with uvicorn, complete with code snippets and testing instructions.

AsyncFastAPIMessage Queue
0 likes · 7 min read
How to Build a FastAPI Service with RabbitMQ Consumer & Publisher
Code Mala Tang
Code Mala Tang
May 10, 2025 · Backend Development

Master FastAPI Request Body Validation with Pydantic Models

This guide explains how FastAPI uses Pydantic models to define, validate, and parse JSON and form request bodies, set default values and custom rules, handle nested structures, and return response models, providing a type‑safe, efficient way to build backend APIs.

API designFastAPIPydantic
0 likes · 8 min read
Master FastAPI Request Body Validation with Pydantic Models
Code Mala Tang
Code Mala Tang
May 9, 2025 · Backend Development

How to Render HTML with FastAPI and Jinja2: A Step‑by‑Step Guide

This tutorial walks you through installing FastAPI, setting up a project structure, creating routes that serve Jinja2‑rendered HTML pages, adding static files, building forms, and mastering essential Jinja2 syntax such as variables, conditionals, loops, template inheritance, filters, macros, and security considerations.

FastAPIHTML renderingJinja2
0 likes · 7 min read
How to Render HTML with FastAPI and Jinja2: A Step‑by‑Step Guide
Code Mala Tang
Code Mala Tang
May 8, 2025 · Backend Development

Mastering Exception Handling in FastAPI: Strategies, Patterns, and Code

Learn how to design robust exception handling for FastAPI applications by combining Look‑Before‑You‑Leap and EAFP strategies, creating custom exception classes, organizing handlers, and integrating them into your API to improve maintainability, clarity, and error response consistency.

Custom ExceptionsError ManagementException Handling
0 likes · 19 min read
Mastering Exception Handling in FastAPI: Strategies, Patterns, and Code