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

FastAPI · Tutorial · all subjects

bigger-applications/apirouter

3 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

APIRouter class for organizing path operations

Use `APIRouter` to group related path operations into separate modules. Import it with `from fastapi import APIRouter`. Create an instance with `router = APIRouter()`, then use it like the `FastAPI` class to declare path operations with `@router.get()`, `@router.post()`, etc. All options supported by `FastAPI` (parameters, responses, dependencies, tags) are supported by `APIRouter`.

APIRouter configuration parameters for path operations

When creating an `APIRouter`, you can pass configuration that applies to all path operations in that router: `prefix` (string, path prefix for all routes), `tags` (list of strings for grouping in documentation), `responses` (dict of response models), and `dependencies` (list of dependencies to execute for all routes). Path operations in the router must start with '/', and the prefix must not end with '/'.

Router dependencies execution order

When a path operation belongs to a router with dependencies, and the path operation also declares its own dependencies, they execute in this order: (1) router dependencies first, (2) then dependencies from the path operation decorator, (3) then normal parameter dependencies. Router dependencies do not pass values to path operation functions. If using `Security` dependencies with scopes, they can also be applied at the router level.

Give your agent this brain