from fastapi import APIRouter, UploadFile, File, HTTPException, status from lib.hugging_face import classify_art router = APIRouter() ALLOWED_TYPES = [ "image/jpeg", "image/jpg", "image/png", "image/webp", "image/avif", "image/gif", "image/bmp", "image/tiff", "image/svg+xml", ] @router.post("/") async def classify(file: UploadFile = File(...)): if file.content_type not in ALLOWED_TYPES: raise HTTPException( status_code=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE, detail=f"Unsupported file type: {file.content_type}. Allowed: {', '.join(ALLOWED_TYPES)}" ) return await classify_art(file)