- Sort Score
- Num 10 results
- Language All
Results 1 - 5 of 5 for stream_items (0.09 seconds)
-
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_src/server_sent_events/tutorial004_py310.py
items = [ Item(name="Plumbus", price=32.99), Item(name="Portal Gun", price=999.99), Item(name="Meeseeks Box", price=49.99), ] @app.get("/items/stream", response_class=EventSourceResponse) async def stream_items( last_event_id: Annotated[int | None, Header()] = None, ) -> AsyncIterable[ServerSentEvent]: start = last_event_id + 1 if last_event_id is not None else 0 for i, item in enumerate(items): if i < start:Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Mar 01 09:21:52 GMT 2026 - 795 bytes - Click Count (0) -
docs_src/server_sent_events/tutorial002_py310.py
items = [ Item(name="Plumbus", price=32.99), Item(name="Portal Gun", price=999.99), Item(name="Meeseeks Box", price=49.99), ] @app.get("/items/stream", response_class=EventSourceResponse) async def stream_items() -> AsyncIterable[ServerSentEvent]: yield ServerSentEvent(comment="stream of item updates") for i, item in enumerate(items):Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Mar 01 09:21:52 GMT 2026 - 686 bytes - Click Count (0) -
docs_src/stream_json_lines/tutorial001_py310.py
Item(name="Portal Gun", description="A portal opening device."), Item(name="Meeseeks Box", description="A box that summons a Meeseeks."), ] @app.get("/items/stream") async def stream_items() -> AsyncIterable[Item]: for item in items: yield item @app.get("/items/stream-no-async") def stream_items_no_async() -> Iterable[Item]: for item in items: yield item
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Feb 27 18:56:47 GMT 2026 - 936 bytes - Click Count (0) -
fastapi/routing.py
if lenient_issubclass(return_annotation, Response): response_model = None else: stream_item = get_stream_item_type(return_annotation) if stream_item is not None: # Extract item type for JSONL or SSE streaming when # response_class is DefaultPlaceholder (JSONL) or
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Mar 15 11:44:39 GMT 2026 - 193K bytes - Click Count (0)