mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-01 10:37:47 -05:00
16 lines
380 B
Python
16 lines
380 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}
|