-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathapp.py
executable file
·36 lines (26 loc) · 834 Bytes
/
app.py
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
27
28
29
30
31
32
33
34
35
36
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
import fastapi as _fapi
import schemas as _schemas
import services as _services
import traceback
app = FastAPI()
@app.get("/")
def read_root():
return {"message": "Welcome to AI Photo Enhancer API"}
# Endpoint to test the backend
@app.get("/api")
async def root():
return {"message": "Welcome to the AI Photo Enhancer with FastAPI"}
@app.post("/api/enhance/")
async def enhance_image(enhanceBase: _schemas._EnhanceBase = _fapi.Depends()):
try:
encoded_img = await _services.enhance(enhanceBase=enhanceBase)
except Exception as e:
print(traceback.format_exc())
return {"message": f"{e.args}"}
payload = {
"mime" : "image/jpg",
"image": encoded_img
}
return payload