from fastapi import FastAPI, Form from fastapi.responses import StreamingResponse from PIL import Image, ImageDraw, ImageFont import io app = FastAPI() @app.get("/") def greet_json(): return {"Hello": "World!"} @app.get("/get-image") async def get_image(filename: str): image_path = f"{filename}" if not os.path.exists(image_path): return {"error": "Image not found"} return FileResponse(image_path, media_type="image/jpeg", filename=filename) # Create a blank image