- Sort Score
- Num 10 results
- Language All
Results 11 - 20 of 315 for router (0.08 seconds)
-
tests/test_dependency_yield_scope.py
) return StreamingResponse(iter_data()) app.include_router( prefix="/router-scope-function", router=router, dependencies=[Depends(raise_after_yield, scope="function")], ) app.include_router( prefix="/router-scope-request", router=router, dependencies=[Depends(raise_after_yield, scope="request")], ) client = TestClient(app)Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 6.7K bytes - Click Count (0) -
tests/test_router_redirect_slashes.py
from fastapi import APIRouter, FastAPI from fastapi.testclient import TestClient def test_redirect_slashes_enabled(): app = FastAPI() router = APIRouter() @router.get("/hello/") def hello_page() -> str: return "Hello, World!" app.include_router(router) client = TestClient(app) response = client.get("/hello/", follow_redirects=False) assert response.status_code == 200
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Jun 22 10:37:50 GMT 2023 - 974 bytes - Click Count (0) -
tests/test_empty_router.py
import pytest from fastapi import APIRouter, FastAPI from fastapi.exceptions import FastAPIError from fastapi.testclient import TestClient app = FastAPI() router = APIRouter() @router.get("") def get_empty(): return ["OK"] app.include_router(router, prefix="/prefix") client = TestClient(app) def test_use_empty(): with client: response = client.get("/prefix")
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Jun 11 22:37:34 GMT 2023 - 805 bytes - Click Count (1) -
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) -
docs_src/custom_request_and_route/tutorial003_py310.py
response.headers["X-Response-Time"] = str(duration) print(f"route duration: {duration}") print(f"route response: {response}") print(f"route response headers: {response.headers}") return response return custom_route_handler app = FastAPI() router = APIRouter(route_class=TimedRoute) @app.get("/") async def not_timed():
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 10 08:55:32 GMT 2025 - 1K 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)