new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

explore / Backend & APIs / mozg / FastAPI

FastAPI · Advanced

Answer questions from the FastAPI advanced guide: advanced dependency patterns, sub-applications and mounting, WebSockets, lifespan events, custom request and APIRoute classes, and the advanced security setups.

234 notes · updated 2026-08-09 · trained 87%

use this brain
# sign in to get a token
$ claude mcp add --transport http mozg \
https://mozg.sh/mcp --header "Authorization: Bearer …"
> use mozg/fastapi-advanced — …
Sign in — get this command with your token in it

New here? Sign in and this exact command appears with your token already inside — copy, paste into your terminal, done.

Or just add it

Sign in and add it, and every agent you have connected can read it — nothing to download, and it stays current as the author updates it.

Sign in to add it

Ask it things like

answers 26/30 on its latest exam
How do I create a dependency that can be configured with parameters at declaration time?Advanced Dependencies & Parameterized Patterns
What is the purpose of the SecurityScopes class in advanced security patterns?Advanced Security
How do you verify scopes in token validation for advanced security setups?Advanced Security
What is the difference between returning a response_model versus a Response object directly?Custom Request & Response Classes
What happens when you return a Response object directly from a path operation?Custom Request & Response Classes
What is the recommended pattern for implementing lifespan events in modern FastAPI?Lifespan Events
What does app.dependency_overrides attribute do in testing?Testing & Advanced Patterns
What is the basic syntax for receiving and sending messages in a WebSocket endpoint?WebSockets

What it can answer

30 coverage checks
87%
Answers 26 of the exam's 30 questions
Custom Request & Response Classes5 / 5
WebSockets5 / 5
Advanced Security4 / 5
Lifespan Events4 / 5
Sub-applications & Mounting4 / 5
Advanced Dependencies & Parameterized Patterns3 / 4
Testing & Advanced Patterns1 / 1
exam badge — share this score →

Attacks survived

re-run weekly · 2026-08-09
gate-battery12/12 known hostile payloads caught by the ingest gate
injection-corpusevery active note scanned — no steering language
secret-corpusevery active note scanned — no keys or credentials

heuristic scans against known attack classes — measured and dated, not a promise of unpoisonability

Inside

  • TestClient for WebSocket testing · testing
  • Mounting WSGI application example with Flask · sub-applications
  • Using WSGIMiddleware to mount WSGI applications · sub-applications
  • a2wsgi package requirement for WSGIMiddleware · sub-applications
  • Deprecated WSGIMiddleware import location · sub-applications
  • In-memory WebSocket broadcasting limitations · websockets
  • WebSocket installation requirement · websockets
  • WebSocket dependency injection · websockets
  • WebSocket API syntax in FastAPI · websockets
  • WebSocketDisconnect exception handling · websockets
  • Await for messages and send messages in WebSocket · websockets
  • WebSocketException vs HTTPException in WebSocket endpoints · websockets
  • Data from Request object bypasses validation and documentation · advanced-dependencies/middleware
  • Request can coexist with other path parameters · advanced-dependencies/middleware

Licence

CC BY-NC-SA 4.0

Use it, copy it, build on it, with credit. Selling it is not allowed.