add info on /
This commit is contained in:
parent
3d92973fab
commit
71a17f4252
1 changed files with 6 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
||||||
import fastapi
|
import fastapi
|
||||||
from PIL import Image, ImageDraw, ImageFont
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
from fastapi.responses import PlainTextResponse
|
||||||
app = fastapi.FastAPI()
|
app = fastapi.FastAPI()
|
||||||
|
|
||||||
img = Image.open("./smoking-caterpillar.jpg")
|
img = Image.open("./smoking-caterpillar.jpg")
|
||||||
|
@ -9,6 +11,10 @@ font = ImageFont.truetype("./unicode.impact.ttf", 72)
|
||||||
class JPEGResponse(fastapi.Response):
|
class JPEGResponse(fastapi.Response):
|
||||||
media_type="image/jpeg"
|
media_type="image/jpeg"
|
||||||
|
|
||||||
|
@app.get("/", response_class=PlainTextResponse)
|
||||||
|
async def root():
|
||||||
|
return "go to /image for the funny thingy"
|
||||||
|
|
||||||
@app.get("/img", response_class=JPEGResponse)
|
@app.get("/img", response_class=JPEGResponse)
|
||||||
async def getImage(request: fastapi.Request):
|
async def getImage(request: fastapi.Request):
|
||||||
img2 = img.copy()
|
img2 = img.copy()
|
||||||
|
|
Loading…
Reference in a new issue