mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-30 01:30:13 -05:00
Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com> Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com>
16 lines
371 B
Python
16 lines
371 B
Python
from fastapi import FastAPI, File, UploadFile
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.post("/files/")
|
|
async def create_file(file: bytes = File(description="A file read as bytes")):
|
|
return {"file_size": len(file)}
|
|
|
|
|
|
@app.post("/uploadfile/")
|
|
async def create_upload_file(
|
|
file: UploadFile = File(description="A file read as UploadFile"),
|
|
):
|
|
return {"filename": file.filename}
|