🔧 Configure strict pytest options and update/refactor tests (#2790)

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
Thomas Grainger
2021-07-19 20:14:58 +01:00
committed by GitHub
parent 71c96d9eb9
commit 2d296c5d07
9 changed files with 147 additions and 129 deletions

View File

@@ -7,5 +7,8 @@ app = FastAPI()
@app.get("/")
def main():
file_like = open(some_file_path, mode="rb")
return StreamingResponse(file_like, media_type="video/mp4")
def iterfile(): # (1)
with open(some_file_path, mode="rb") as file_like: # (2)
yield from file_like # (3)
return StreamingResponse(iterfile(), media_type="video/mp4")