- Sort Score
- Num 10 results
- Language All
Results 1 - 10 of 184 for router (0.04 seconds)
-
tests/test_dependency_overrides.py
@router.get("/router-depends/") async def router_depends(commons: dict = Depends(common_parameters)): return {"in": "router-depends", "params": commons} @router.get("/router-decorator-depends/", dependencies=[Depends(common_parameters)]) async def router_decorator_depends(): return {"in": "router-decorator-depends"} app.include_router(router) client = TestClient(app)
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 17 09:59:14 GMT 2026 - 11.2K bytes - Click Count (0) -
tests/test_router_events.py
sub_router = APIRouter(lifespan=subrouter_lifespan) router = APIRouter(lifespan=router_lifespan) router.include_router(sub_router) app = FastAPI(lifespan=lifespan) app.include_router(router) @app.get("/") def main(request: Request) -> dict[str, str]: assert request.state.app assert request.state.router assert request.state.sub_routerCreated: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 17 09:59:14 GMT 2026 - 11.7K bytes - Click Count (0) -
docs/en/docs/tutorial/bigger-applications.md
We are importing the submodule `items` directly, instead of importing just its variable `router`. This is because we also have another variable named `router` in the submodule `users`. If we had imported one after the other, like: ```Python from .routers.items import router from .routers.users import router ```
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sat Mar 07 09:29:03 GMT 2026 - 19.2K bytes - Click Count (0) -
tests/test_router_circular_import.py
import pytest from fastapi import APIRouter def test_router_circular_import(): router = APIRouter() with pytest.raises( AssertionError, match="Cannot include the same APIRouter instance into itself. Did you mean to include a different router?", ):
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 10 10:58:40 GMT 2026 - 317 bytes - Click Count (0) -
tests/test_custom_route_class.py
@router_b.get("/") def get_b(): return {"msg": "B"} @router_c.get("/") def get_c(): return {"msg": "C"} router_b.include_router(router=router_c, prefix="/c") router_a.include_router(router=router_b, prefix="/b") app.include_router(router=router_a, prefix="/a") client = TestClient(app) @pytest.mark.parametrize( "path,expected_status,expected_response", [
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Feb 08 10:18:38 GMT 2026 - 3.3K bytes - Click Count (0) -
fastapi/routing.py
if responses is None: responses = {} for route in router.routes: if isinstance(route, APIRoute): combined_responses = {**responses, **route.responses} use_response_class = get_value_or_default( route.response_class, router.default_response_class, default_response_class,Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Mar 15 11:44:39 GMT 2026 - 193K bytes - Click Count (0) -
tests/test_strict_content_type_nested.py
response = client_nested.post("/outer/strict/items/", json={"key": "value"}) assert response.status_code == 200 def test_default_inner_accepts_json_content_type(): response = client_nested.post("/outer/default/items/", json={"key": "value"}) assert response.status_code == 200 # Strict app -> lax outer router -> strict inner router app_mixed = FastAPI(strict_content_type=True)
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Mon Feb 23 17:45:20 GMT 2026 - 2.7K bytes - Click Count (0) -
fastapi/.agents/skills/fastapi/SKILL.md
## Including Routers When declaring routers, prefer to add router level parameters like prefix, tags, etc. to the router itself, instead of in `include_router()`. Do this: ```python from fastapi import APIRouter, FastAPI app = FastAPI() router = APIRouter(prefix="/items", tags=["items"]) @router.get("/") async def list_items(): return []
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Mar 01 10:05:57 GMT 2026 - 10.1K bytes - Click Count (0) -
docs/en/docs/advanced/openapi-callbacks.md
/// ### Add the callback router { #add-the-callback-router } At this point you have the *callback path operation(s)* needed (the one(s) that the *external developer* should implement in the *external API*) in the callback router you created above. Now use the parameter `callbacks` in *your API's path operation decorator* to pass the attribute `.routes` (that's actually just a `list` of routes/*path operations*) from that callback router:Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 7.7K bytes - Click Count (0) -
docs/en/docs/how-to/custom-request-and-route.md
## Custom `APIRoute` class in a router { #custom-apiroute-class-in-a-router } You can also set the `route_class` parameter of an `APIRouter`: {* ../../docs_src/custom_request_and_route/tutorial003_py310.py hl[26] *}Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 4.4K bytes - Click Count (0)