saifvj's picture
Update app.py
9f60a10 verified
Raw History Blame Contribute Delete
406 Bytes
from fastapi import FastAPI, UploadFile, File
import os
app = FastAPI()
UPLOAD_DIR = "uploads"
os.makedirs(UPLOAD_DIR, exist_ok=True)
@app.post("/upload")
async def upload(file: UploadFile = File(...)):
filepath = os.path.join(UPLOAD_DIR, file.filename)
with open(filepath, "wb") as f:
f.write(await file.read())
return {
"success": True,
"saved_to": filepath
}