- Sort Score
- Result 10 results
- Languages All
Results 401 - 410 of 1,127 for def2 (0.03 sec)
-
docs_src/generate_clients/tutorial001_py39.py
price: float class ResponseMessage(BaseModel): message: str @app.post("/items/", response_model=ResponseMessage) async def create_item(item: Item): return {"message": "item received"} @app.get("/items/", response_model=list[Item]) async def get_items(): return [ {"name": "Plumbus", "price": 3}, {"name": "Portal Gun", "price": 9001},
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Mar 04 22:02:18 UTC 2022 - 494 bytes - Viewed (0) -
tests/test_param_class.py
app = FastAPI() @app.get("/items/") def read_items(q: Optional[str] = Param(default=None)): # type: ignore return {"q": q} client = TestClient(app) def test_default_param_query_none(): response = client.get("/items/") assert response.status_code == 200, response.text assert response.json() == {"q": None} def test_default_param_query(): response = client.get("/items/?q=foo")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri May 13 23:38:22 UTC 2022 - 636 bytes - Viewed (0) -
docs_src/dependencies/tutorial006_an.py
from fastapi import Depends, FastAPI, Header, HTTPException from typing_extensions import Annotated app = FastAPI() async def verify_token(x_token: Annotated[str, Header()]): if x_token != "fake-super-secret-token": raise HTTPException(status_code=400, detail="X-Token header invalid") async def verify_key(x_key: Annotated[str, Header()]): if x_key != "fake-super-secret-key":
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 643 bytes - Viewed (0) -
docs_src/dependencies/tutorial006_an_py39.py
from typing import Annotated from fastapi import Depends, FastAPI, Header, HTTPException app = FastAPI() async def verify_token(x_token: Annotated[str, Header()]): if x_token != "fake-super-secret-token": raise HTTPException(status_code=400, detail="X-Token header invalid") async def verify_key(x_key: Annotated[str, Header()]): if x_key != "fake-super-secret-key":
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 633 bytes - Viewed (0) -
tests/test_additional_responses_custom_model_in_callback.py
@callback_router.get( "{$callback_url}/callback/", responses={400: {"model": CustomModel}} ) def callback_route(): pass # pragma: no cover @app.post("/", callbacks=callback_router.routes) def main_route(callback_url: HttpUrl): pass # pragma: no cover client = TestClient(app) def test_openapi_schema(): response = client.get("/openapi.json")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 5.8K bytes - Viewed (0) -
tests/test_tutorial/test_header_params/test_tutorial003_py310.py
], ) def test(path, headers, expected_status, expected_response, client: TestClient): response = client.get(path, headers=headers) assert response.status_code == expected_status assert response.json() == expected_response @needs_py310 def test_openapi_schema(client: TestClient): response = client.get("/openapi.json")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 4.3K bytes - Viewed (0) -
docs_src/separate_openapi_schemas/tutorial001_py39.py
from pydantic import BaseModel class Item(BaseModel): name: str description: Optional[str] = None app = FastAPI() @app.post("/items/") def create_item(item: Item): return item @app.get("/items/") def read_items() -> list[Item]: return [ Item( name="Portal Gun", description="Device to travel through the multi-rick-verse", ),
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Aug 25 19:10:22 UTC 2023 - 483 bytes - Viewed (0) -
docs_src/generate_clients/tutorial001.py
price: float class ResponseMessage(BaseModel): message: str @app.post("/items/", response_model=ResponseMessage) async def create_item(item: Item): return {"message": "item received"} @app.get("/items/", response_model=List[Item]) async def get_items(): return [ {"name": "Plumbus", "price": 3}, {"name": "Portal Gun", "price": 9001},
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Mar 04 22:02:18 UTC 2022 - 519 bytes - Viewed (0) -
tests/test_router_prefix_with_template.py
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") assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Wed Apr 08 04:37:38 UTC 2020 - 484 bytes - Viewed (0) -
tests/test_tutorial/test_additional_status_codes/test_tutorial001_py310.py
import pytest from fastapi.testclient import TestClient from ...utils import needs_py310 @pytest.fixture(name="client") def get_client(): from docs_src.additional_status_codes.tutorial001_py310 import app client = TestClient(app) return client @needs_py310 def test_update(client: TestClient): response = client.put("/items/foo", json={"name": "Wrestlers"}) assert response.status_code == 200, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 738 bytes - Viewed (0)