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 @app.post("/uploadfile/") 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)}")