File size: 498 Bytes
91131a9
 
 
 
7e2bd1e
 
 
 
 
 
e34bebd
f2c2f6d
 
16aea7d
f2c2f6d
 
30de5cf
e34bebd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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