- Sort Score
- Num 10 results
- Language All
Results 1 - 10 of 53 for StreamingResponse (0.57 seconds)
-
docs_src/stream_data/tutorial001_py310.py
@app.get("/story/stream-no-annotation", response_class=StreamingResponse) async def stream_story_no_annotation(): for line in message.splitlines(): yield line @app.get("/story/stream-no-async-no-annotation", response_class=StreamingResponse) def stream_story_no_async_no_annotation(): for line in message.splitlines(): yield line @app.get("/story/stream-bytes", response_class=StreamingResponse)
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Feb 27 18:56:47 GMT 2026 - 2.2K bytes - Click Count (0) -
fastapi/.agents/skills/fastapi/references/streaming.md
``` ## Stream bytes To stream bytes, declare a `response_class=` of `StreamingResponse` or a sub-class, and use `yield` to return the data. ```python from fastapi import FastAPI from fastapi.responses import StreamingResponse from app.utils import read_image app = FastAPI() class PNGStreamingResponse(StreamingResponse): media_type = "image/png" @app.get("/image", response_class=PNGStreamingResponse)
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) -
tests/test_dependency_yield_scope.py
def iter_data(): yield json.dumps({"is_open": session.open}) return StreamingResponse(iter_data()) @app.get("/request-scope") def request_scope(session: SessionRequestDep) -> Any: def iter_data(): yield json.dumps({"is_open": session.open}) return StreamingResponse(iter_data()) @app.get("/two-scopes") def get_stream_session(
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 6.7K bytes - Click Count (0) -
tests/test_dependency_after_yield_streaming.py
def get_stream_simple(session: SessionDep) -> Any: def iter_data(): yield from ["x", "y", "z"] return StreamingResponse(iter_data()) @app.get("/stream-session") def get_stream_session(session: SessionDep) -> Any: def iter_data(): yield from session return StreamingResponse(iter_data()) @app.get("/broken-session-data") def get_broken_session_data(session: BrokenSessionDep) -> Any:
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 17 21:25:59 GMT 2025 - 3.2K bytes - Click Count (0) -
docs/en/docs/advanced/stream-data.md
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Mar 05 18:13:19 GMT 2026 - 5.4K bytes - Click Count (0) -
docs/zh-hant/docs/advanced/stream-data.md
你也可以用它來串流大型二進位檔案,邊讀邊將每個區塊(chunk)串流出去,而不必一次把整個檔案載入記憶體。 你也可以用同樣方式串流視訊或音訊,甚至可以在處理的同時即時產生並傳送。 ## 使用 `yield` 的 `StreamingResponse` { #a-streamingresponse-with-yield } 如果在你的路徑操作函式中宣告 `response_class=StreamingResponse`,就可以用 `yield` 逐一送出每個資料區塊。 {* ../../docs_src/stream_data/tutorial001_py310.py ln[1:23] hl[20,23] *} FastAPI 會如實將每個資料區塊交給 `StreamingResponse`,不會嘗試將其轉換為 JSON 或其他格式。 ### 非 async 路徑操作函式 { #non-async-path-operation-functions }Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:33:04 GMT 2026 - 4.9K bytes - Click Count (0) -
docs_src/custom_response/tutorial007_py310.py
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Feb 27 19:12:46 GMT 2026 - 319 bytes - Click Count (0) -
docs_src/custom_response/tutorial008_py310.py
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 360 bytes - Click Count (0) -
docs_src/stream_data/tutorial002_py310.py
import base64 from collections.abc import AsyncIterable, Iterable from io import BytesIO from fastapi import FastAPI from fastapi.responses import StreamingResponse
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Feb 27 20:51:40 GMT 2026 - 5.6K bytes - Click Count (0) -
docs/zh/docs/advanced/stream-data.md
你也可以用它来流式传输大型二进制文件,在读取的同时按块发送,无需一次性把所有内容读入内存。 你还可以用这种方式流式传输视频或音频,甚至可以在处理的同时生成并发送。 ## 使用 `yield` 的 `StreamingResponse` { #a-streamingresponse-with-yield } 如果你在*路径操作函数*中声明 `response_class=StreamingResponse`,你就可以使用 `yield` 依次发送每个数据块。 {* ../../docs_src/stream_data/tutorial001_py310.py ln[1:23] hl[20,23] *} FastAPI 会将每个数据块原样交给 `StreamingResponse`,不会尝试将其转换为 JSON 或做类似处理。 ### 非 async 的*路径操作函数* { #non-async-path-operation-functions }Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:29:48 GMT 2026 - 5.2K bytes - Click Count (0)