Spaces:
Sleeping
Sleeping
File size: 971 Bytes
0622d45 c954778 2ffce71 c954778 0622d45 c954778 0622d45 c954778 263b8b7 983f3dc 0622d45 c954778 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import os
from fastapi import APIRouter, UploadFile, File
from starlette.responses import JSONResponse
from app.utils.file_utils import save_upload_image
router = APIRouter()
BASE_URL = "https://esteele-funny-meme-generator.hf.space"
@router.post("/upload")
async def upload_file(file: UploadFile = File(...)):
try:
print("Uploading file...")
file_path = save_upload_image(file)
return JSONResponse(
content={
"success": True,
"message": "✅ Upload complete!",
"filename": os.path.basename(file_path),
"next_step": "Now you can generate a meme caption 🎉"
# "preview_url": f"{BASE_URL}/static/uploads/{os.path.basename(file_path)}"
}
)
# return JSONResponse(content={"message": "File uploaded", "path": file_path})
except Exception as e:
return JSONResponse(content={"error": str(e)}, status_code=500)
|