- Sort Score
- Num 10 results
- Language All
Results 81 - 90 of 223 for routers (0.83 seconds)
-
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_include_route.py
from fastapi.responses import JSONResponse from fastapi.testclient import TestClient app = FastAPI() router = APIRouter() @router.route("/items/") def read_items(request: Request): return JSONResponse({"hello": "world"}) app.include_router(router) client = TestClient(app) def test_sub_router(): response = client.get("/items/")
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Apr 08 04:37:38 GMT 2020 - 496 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) -
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) -
tests/test_additional_responses_router.py
message: str app = FastAPI() router = APIRouter() @router.get("/a", responses={501: {"description": "Error 1"}}) async def a(): return "a" @router.get( "/b", responses={ 502: {"description": "Error 2"}, "4XX": {"description": "Error with range, upper"}, }, ) async def b(): return "b" @router.get( "/c", responses={
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Feb 08 10:18:38 GMT 2026 - 5.6K bytes - Click Count (0) -
tests/test_additional_response_extra.py
from fastapi.testclient import TestClient from inline_snapshot import snapshot router = APIRouter() sub_router = APIRouter() app = FastAPI() @sub_router.get("/") def read_item(): return {"id": "foo"} router.include_router(sub_router, prefix="/items") app.include_router(router) client = TestClient(app) def test_path_operation(): response = client.get("/items/")
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Feb 08 10:18:38 GMT 2026 - 1.3K bytes - Click Count (0) -
okhttp-testing-support/src/main/kotlin/okhttp3/internal/RecordingOkAuthenticator.kt
import okhttp3.Response import okhttp3.Route class RecordingOkAuthenticator( val credential: String?, val scheme: String?, ) : Authenticator { val responses = mutableListOf<Response>() val routes = mutableListOf<Route>() fun onlyResponse() = responses.single() fun onlyRoute() = routes.single() @Throws(IOException::class) override fun authenticate( route: Route?, response: Response,
Created: Fri Apr 03 11:42:14 GMT 2026 - Last Modified: Wed Mar 19 19:25:20 GMT 2025 - 1.7K bytes - Click Count (0) -
tests/test_modules_same_name_body/app/b.py
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri May 13 23:38:22 GMT 2022 - 161 bytes - Click Count (0) -
tests/test_router_prefix_with_template.py
from fastapi import APIRouter, FastAPI from fastapi.testclient import TestClient app = FastAPI() router = APIRouter() @router.get("/users/{id}") def read_user(segment: str, id: str): return {"segment": segment, "id": id} app.include_router(router, prefix="/{segment}") client = TestClient(app) def test_get(): response = client.get("/seg/users/foo")
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Apr 08 04:37:38 GMT 2020 - 484 bytes - Click Count (0) -
tests/test_security_oauth2_authorization_code_bearer_scopes_openapi.py
) async def read_with_get_token(): return {"message": "Admin Access"} router = APIRouter(dependencies=[Security(oauth2_scheme, scopes=["read"])]) @router.get("/items/") async def read_items(token: str | None = Depends(oauth2_scheme)): return {"token": token} @router.post("/items/") async def create_item( token: str | None = Security(oauth2_scheme, scopes=["read", "write"]), ):
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 17 09:59:14 GMT 2026 - 6.6K bytes - Click Count (0)