- Sort Score
- Num 10 results
- Language All
Results 71 - 80 of 1,038 for Async (0.03 seconds)
-
docs_src/path_operation_configuration/tutorial006_py310.py
from fastapi import FastAPI app = FastAPI() @app.get("/items/", tags=["items"]) async def read_items(): return [{"name": "Foo", "price": 42}] @app.get("/users/", tags=["users"]) async def read_users(): return [{"username": "johndoe"}] @app.get("/elements/", tags=["items"], deprecated=True) async def read_elements():
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 365 bytes - Click Count (0) -
tests/test_http_connection_injection.py
from starlette.websockets import WebSocket app = FastAPI() app.state.value = 42 async def extract_value_from_http_connection(conn: HTTPConnection): return conn.app.state.value @app.get("/http") async def get_value_by_http(value: int = Depends(extract_value_from_http_connection)): return value @app.websocket("/ws") async def get_value_by_ws(
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Aug 09 13:56:41 GMT 2020 - 972 bytes - Click Count (0) -
docs_src/bigger_applications/app_an_py310/routers/items.py
responses={404: {"description": "Not found"}}, ) fake_items_db = {"plumbus": {"name": "Plumbus"}, "gun": {"name": "Portal Gun"}} @router.get("/") async def read_items(): return fake_items_db @router.get("/{item_id}") async def read_item(item_id: str): if item_id not in fake_items_db: raise HTTPException(status_code=404, detail="Item not found")Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 1011 bytes - Click Count (0) -
docs_src/custom_request_and_route/tutorial003_py310.py
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_annotated.py
from inline_snapshot import snapshot app = FastAPI() @app.get("/default") async def default(foo: Annotated[str, Query()] = "foo"): return {"foo": foo} @app.get("/required") async def required(foo: Annotated[str, Query(min_length=1)]): return {"foo": foo} @app.get("/multiple") async def multiple(foo: Annotated[str, object(), Query(min_length=1)]): return {"foo": foo}
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Feb 08 10:18:38 GMT 2026 - 10.5K bytes - Click Count (0) -
tests/test_dependency_overrides.py
app = FastAPI() router = APIRouter() async def common_parameters(q: str, skip: int = 0, limit: int = 100): return {"q": q, "skip": skip, "limit": limit} @app.get("/main-depends/") async def main_depends(commons: dict = Depends(common_parameters)): return {"in": "main-depends", "params": commons} @app.get("/decorator-depends/", dependencies=[Depends(common_parameters)]) async def decorator_depends():
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) -
docs_src/generate_clients/tutorial002_py310.py
async def create_item(item: Item): return {"message": "Item received"} @app.get("/items/", response_model=list[Item], tags=["items"]) async def get_items(): return [ {"name": "Plumbus", "price": 3}, {"name": "Portal Gun", "price": 9001}, ] @app.post("/users/", response_model=ResponseMessage, tags=["users"]) async def create_user(user: User):
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 730 bytes - Click Count (0) -
fastapi/.agents/skills/fastapi/references/streaming.md
# Streaming ## Stream JSON Lines To stream JSON Lines, declare the return type and use `yield` to return the data. ```python @app.get("/items/stream") async def stream_items() -> AsyncIterable[Item]: for item in items: yield item ``` ## Server-Sent Events (SSE) To stream Server-Sent Events, use `response_class=EventSourceResponse` and `yield` items from the endpoint.
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Mar 01 10:05:57 GMT 2026 - 2.5K bytes - Click Count (0) -
docs/en/docs/tutorial/stream-json-lines.md
/// ### Non-async *path operation functions* { #non-async-path-operation-functions } You can also use regular `def` functions (without `async`), and use `yield` the same way. FastAPI will make sure it's run correctly so that it doesn't block the event loop. As in this case the function is not async, the right return type would be `Iterable[Item]`:Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 4.3K bytes - Click Count (0) -
docs_src/request_files/tutorial002_an_py310.py
app = FastAPI() @app.post("/files/") async def create_files(files: Annotated[list[bytes], File()]): return {"file_sizes": [len(file) for file in files]} @app.post("/uploadfiles/") async def create_upload_files(files: list[UploadFile]): return {"filenames": [file.filename for file in files]} @app.get("/") async def main(): content = """ <body>
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 826 bytes - Click Count (0)