Coverage for docs_src/custom_response/tutorial008.py: 100%
10 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
1from fastapi import FastAPI 1abcdef
2from fastapi.responses import StreamingResponse 1abcdef
4some_file_path = "large-video-file.mp4" 1abcdef
5app = FastAPI() 1abcdef
8@app.get("/") 1abcdef
9def main(): 1abcdef
10 def iterfile(): # (1) 1ghijkl
11 with open(some_file_path, mode="rb") as file_like: # (2) 1ghijkl
12 yield from file_like # (3) 1ghijkl
14 return StreamingResponse(iterfile(), media_type="video/mp4") 1ghijkl