StreamingResponse (FastAPI)
Takes an async generator or a normal generator/iterator and streams the response body.
StreamingResponse(非同期イテレータ または 通常のイテレータ)
Using StreamingResponse with file-like objects
If you have a file-like object (e.g. the object returned by open()), you can create a generator function to iterate over that file-like object.
yield from file_like_object
パス関数をdefにしているのは組み込みのopenはasync/awaitをサポートしていないため(中でawaitを使う必要がないのでdefで定義)