esteele's picture
Fixed upload bug by turning the space visibility to public
0622d45
raw
history blame contribute delete
971 Bytes
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)