Update main.py
Browse files
main.py
CHANGED
|
@@ -106,6 +106,8 @@ def process_image(img):
|
|
| 106 |
output = img_concat_h(aligned_img, output)
|
| 107 |
return output
|
| 108 |
|
|
|
|
|
|
|
| 109 |
@app.post("/process_image/")
|
| 110 |
async def upload(file: UploadFile = File(...)):
|
| 111 |
contents = await file.read()
|
|
@@ -114,8 +116,7 @@ async def upload(file: UploadFile = File(...)):
|
|
| 114 |
if processed_img:
|
| 115 |
buffered = BytesIO()
|
| 116 |
processed_img.save(buffered, format="JPEG")
|
| 117 |
-
|
| 118 |
-
return FileResponse(io.BytesIO(contents), media_type="image/jpeg")
|
| 119 |
|
| 120 |
|
| 121 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
|
|
|
| 106 |
output = img_concat_h(aligned_img, output)
|
| 107 |
return output
|
| 108 |
|
| 109 |
+
from fastapi.responses import Response
|
| 110 |
+
|
| 111 |
@app.post("/process_image/")
|
| 112 |
async def upload(file: UploadFile = File(...)):
|
| 113 |
contents = await file.read()
|
|
|
|
| 116 |
if processed_img:
|
| 117 |
buffered = BytesIO()
|
| 118 |
processed_img.save(buffered, format="JPEG")
|
| 119 |
+
return Response(content=buffered.getvalue(), media_type="image/jpeg")
|
|
|
|
| 120 |
|
| 121 |
|
| 122 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|