Skip to content
tezvyn:

Python & FastAPI

Python, Django, FastAPI, Flask, async Python

30 bites

Test yourself: Top 30 advanced Python & FastAPI concepts questionsMultiple choice, with the correct answer and why it is correct on every question. Free, no sign-in.

Advanced concepts in Python & FastAPI, page 2

advanced2 min read

CSRF: Double Submit Cookies for Stateless Backends

Double Submit Cookies stop CSRF by requiring a secret in two places: a cookie and a request header. The server just checks if they match. It's useful for stateless APIs where storing server-side tokens is impractical.

Celery: Offloading Work from Your FastAPI App
advanced2 min read

Celery: Offloading Work from Your FastAPI App

Celery lets your web app offload slow tasks to a separate process, keeping your API responsive. Use it for tasks that can't finish in a single HTTP request, like sending bulk emails or processing images.

advanced2 min read

Mocking with Pytest's monkeypatch

Pytest's monkeypatch is a temporary stunt double for your code, safely swapping out functions or environment variables for a single test. Use it to isolate tests from network calls or filesystem access.

Testing WebSockets in FastAPI
advanced2 min read

Testing WebSockets in FastAPI

Test a WebSocket conversation by scripting both sides. FastAPI's TestClient provides a websocket_connect context manager to send messages and assert responses sequentially, which is crucial for testing chats or live data feeds.

advanced2 min read

Overriding FastAPI's OpenAPI Generator

FastAPI lets you swap app.openapi to reshape its generated schema without forking. Use this for vendor extensions, filtered operations, or merging external schemas. Forgetting to cache the result means every docs request rebuilds it and destroys performance.

Customizing FastAPI's Swagger UI Behavior
advanced1 min read

Customizing FastAPI's Swagger UI Behavior

Treat FastAPI's Swagger UI as a configurable frontend, not a static page. You can customize its behavior by passing a dictionary of settings on app startup. This is useful for changing themes or pre-filling auth fields. The footgun: keys must be camelCase.

FastAPI Behind a Reverse Proxy: Fixing Docs URLs
advanced2 min read

FastAPI Behind a Reverse Proxy: Fixing Docs URLs

A reverse proxy can hide the full URL from your FastAPI app, breaking OpenAPI docs. Tell your app about the proxy's path prefix by setting the root_path during initialization to ensure all generated URLs are correct.

advanced2 min read

FastAPI's WebSocket State Machine

FastAPI manages WebSockets with a state machine, tracking client and application states separately. You must explicitly accept() a connection before communicating. This is key for chat or notification features.

Mangum: Run Python ASGI Apps on Serverless
advanced2 min read

Mangum: Run Python ASGI Apps on Serverless

Mangum is an adapter for running Python ASGI apps (like FastAPI) on serverless platforms like AWS Lambda. It translates serverless events into ASGI requests, letting you deploy existing async web apps without a rewrite.

FastAPI Container Build and Deploy Pipeline
advanced2 min read

FastAPI Container Build and Deploy Pipeline

Treat the Docker image as the immutable artifact: one build runs everywhere. Deploy FastAPI workers behind a load balancer, one process per container. The footgun is baking secrets into the image or running multiple processes; that breaks horizontal scaling.

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles