- Sort Score
- Result 10 results
- Languages All
Results 221 - 230 of 274 for head_item (0.06 sec)
-
docs_src/query_params_str_validations/tutorial015_an_py39.py
def check_valid_id(id: str): if not id.startswith(("isbn-", "imdb-")): raise ValueError('Invalid ID format, it must start with "isbn-" or "imdb-"') return id @app.get("/items/") async def read_items( id: Annotated[Union[str, None], AfterValidator(check_valid_id)] = None, ): if id: item = data.get(id) else: id, item = random.choice(list(data.items()))
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Mar 01 22:02:35 UTC 2025 - 781 bytes - Viewed (0) -
fastapi/security/api_key.py
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 9.6K bytes - Viewed (1) -
docs_src/dependency_testing/tutorial001_an_py39.py
app = FastAPI() async def common_parameters( q: Union[str, None] = None, skip: int = 0, limit: int = 100 ): return {"q": q, "skip": skip, "limit": limit} @app.get("/items/") async def read_items(commons: Annotated[dict, Depends(common_parameters)]): return {"message": "Hello Items!", "params": commons} @app.get("/users/") async def read_users(commons: Annotated[dict, Depends(common_parameters)]):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 1.5K bytes - Viewed (0) -
tests/test_security_oauth2_password_bearer_optional_description.py
app = FastAPI() oauth2_scheme = OAuth2PasswordBearer( tokenUrl="/token", description="OAuth2PasswordBearer security scheme", auto_error=False, ) @app.get("/items/") async def read_items(token: Optional[str] = Security(oauth2_scheme)): if token is None: return {"msg": "Create an account first"} return {"token": token} client = TestClient(app) def test_no_token():
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2.2K bytes - Viewed (0) -
docs_src/dependency_testing/tutorial001_py39.py
app = FastAPI() async def common_parameters( q: Union[str, None] = None, skip: int = 0, limit: int = 100 ): return {"q": q, "skip": skip, "limit": limit} @app.get("/items/") async def read_items(commons: dict = Depends(common_parameters)): return {"message": "Hello Items!", "params": commons} @app.get("/users/") async def read_users(commons: dict = Depends(common_parameters)):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 20:41:43 UTC 2025 - 1.5K bytes - Viewed (0) -
docs_src/dependency_testing/tutorial001_an_py310.py
app = FastAPI() async def common_parameters(q: str | None = None, skip: int = 0, limit: int = 100): return {"q": q, "skip": skip, "limit": limit} @app.get("/items/") async def read_items(commons: Annotated[dict, Depends(common_parameters)]): return {"message": "Hello Items!", "params": commons} @app.get("/users/") async def read_users(commons: Annotated[dict, Depends(common_parameters)]):
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 1.5K bytes - Viewed (0) -
tests/test_security_oauth2_authorization_code_bearer_description.py
oauth2_scheme = OAuth2AuthorizationCodeBearer( authorizationUrl="authorize", tokenUrl="token", description="OAuth2 Code Bearer", auto_error=True, ) @app.get("/items/") async def read_items(token: Optional[str] = Security(oauth2_scheme)): return {"token": token} client = TestClient(app) def test_no_token(): response = client.get("/items")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2.4K bytes - Viewed (0) -
tests/test_security_oauth2_password_bearer_optional.py
from fastapi.security import OAuth2PasswordBearer from fastapi.testclient import TestClient app = FastAPI() oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/token", auto_error=False) @app.get("/items/") async def read_items(token: Optional[str] = Security(oauth2_scheme)): if token is None: return {"msg": "Create an account first"} return {"token": token} client = TestClient(app) def test_no_token():
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2.1K bytes - Viewed (0) -
tests/test_multi_query_errors.py
from fastapi import FastAPI, Query from fastapi.testclient import TestClient app = FastAPI() @app.get("/items/") def read_items(q: list[int] = Query(default=None)): return {"q": q} client = TestClient(app) def test_multi_query(): response = client.get("/items/?q=5&q=6") assert response.status_code == 200, response.text assert response.json() == {"q": [5, 6]} def test_multi_query_incorrect():
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Dec 27 18:19:10 UTC 2025 - 3.9K bytes - Viewed (0) -
tests/test_starlette_exception.py
from fastapi.testclient import TestClient from starlette.exceptions import HTTPException as StarletteHTTPException app = FastAPI() items = {"foo": "The Foo Wrestlers"} @app.get("/items/{item_id}") async def read_item(item_id: str): if item_id not in items: raise HTTPException( status_code=404, detail="Item not found", headers={"X-Error": "Some custom header"}, )
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 7.4K bytes - Viewed (0)