Coverage for docs_src/request_files/tutorial001_02_py310.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-08 03:53 +0000

1from fastapi import FastAPI, File, UploadFile 1abc

2 

3app = FastAPI() 1abc

4 

5 

6@app.post("/files/") 1abc

7async def create_file(file: bytes | None = File(default=None)): 1abc

8 if not file: 1abc

9 return {"message": "No file sent"} 1abc

10 else: 

11 return {"file_size": len(file)} 1abc

12 

13 

14@app.post("/uploadfile/") 1abc

15async def create_upload_file(file: UploadFile | None = None): 1abc

16 if not file: 1abc

17 return {"message": "No upload file sent"} 1abc

18 else: 

19 return {"filename": file.filename} 1abc