Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 41 for StreamingResponse (0.69 seconds)

The search processing time has exceeded the limit. The displayed results may be partial.

  1. 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)
  2. 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)
  3. docs/en/docs/advanced/stream-data.md

    ## A `StreamingResponse` with `yield` { #a-streamingresponse-with-yield }
    
    If you declare a `response_class=StreamingResponse` in your *path operation function*, you can use `yield` to send each chunk of data in turn.
    
    {* ../../docs_src/stream_data/tutorial001_py310.py ln[1:23] hl[20,23] *}
    
    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)
  4. 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)
  5. docs_src/custom_response/tutorial007_py310.py

    import anyio
    from fastapi import FastAPI
    from fastapi.responses import StreamingResponse
    
    app = FastAPI()
    
    
    async def fake_video_streamer():
        for i in range(10):
            yield b"some fake video bytes"
            await anyio.sleep(0)
    
    
    @app.get("/")
    async def main():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Feb 27 19:12:46 GMT 2026
    - 319 bytes
    - Click Count (0)
  6. docs_src/custom_response/tutorial008_py310.py

    from fastapi import FastAPI
    from fastapi.responses import StreamingResponse
    
    some_file_path = "large-video-file.mp4"
    app = FastAPI()
    
    
    @app.get("/")
    def main():
        def iterfile():  # (1)
            with open(some_file_path, mode="rb") as file_like:  # (2)
                yield from file_like  # (3)
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 360 bytes
    - Click Count (0)
  7. 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)
  8. 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)
  9. docs/ja/docs/advanced/stream-data.md

    同様に、動画や音声をストリームすることもできます。処理しながら生成し、そのまま送信することも可能です。
    
    ## `yield` を使った `StreamingResponse` { #a-streamingresponse-with-yield }
    
    path operation 関数で `response_class=StreamingResponse` を宣言すると、`yield` を使ってデータをチャンクごとに順次送信できます。
    
    {* ../../docs_src/stream_data/tutorial001_py310.py ln[1:23] hl[20,23] *}
    
    FastAPI は各データチャンクをそのまま `StreamingResponse` に渡し、JSON などに変換しようとはしません。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 18:55:22 GMT 2026
    - 6.7K bytes
    - Click Count (0)
  10. docs/en/docs/advanced/advanced-dependencies.md

    ### Dependencies with `yield` and `StreamingResponse`, Technical Details { #dependencies-with-yield-and-streamingresponse-technical-details }
    
    Before FastAPI 0.118.0, if you used a dependency with `yield`, it would run the exit code after the *path operation function* returned but right before sending the response.
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 9K bytes
    - Click Count (0)
Back to Top