Download api.py from senel/test: direct link, hf CLI and curl.
- Browser
- Download file 649 Bytes
-
https://huggingface.co/spaces/senel/test/resolve/main/api.py
- Command line
-
hf download hf://spaces/senel/test/api.py
-
curl -L -o api.py https://huggingface.co/spaces/senel/test/resolve/main/api.py
649 Bytes
| from fastapi import FastAPI, HTTPException, Form | |
| from pydantic import BaseModel | |
| from typing import Union | |
| import base64 | |
| from PIL import Image | |
| from io import BytesIO | |
| app = FastAPI() | |
| class ImageData(BaseModel): | |
| image: str | |
| async def uploadfile(image_data: ImageData): | |
| try: | |
| # Base64 string'ini decode et | |
| image_bytes = base64.b64decode(image_data.image) | |
| # Byte verisini PIL Image nesnesine dönüştür | |
| return {"processed_image": "BAŞARILI"} | |
| except Exception as e: | |
| raise HTTPException(status_code=400, detail=f"Image processing error: {str(e)}") | |