File size: 649 Bytes
64a4cf8 5c9f097 64a4cf8 5c9f097 64a4cf8 5c9f097 64a4cf8 8bfaf2e 64a4cf8 ad7846c 64a4cf8 5c9f097 64a4cf8 | 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 | 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)}")
|