Spaces:
Sleeping
Sleeping
Ziad Meligy
commited on
Commit
Β·
57fef69
1
Parent(s):
ac4fea9
Pushing deployment to space
Browse files
main.py
CHANGED
|
@@ -22,13 +22,22 @@ async def read_root():
|
|
| 22 |
@app.post("/upload-image/")
|
| 23 |
async def upload_image(file: UploadFile = File(...)):
|
| 24 |
try:
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
image_io = io.BytesIO()
|
| 27 |
image.save(image_io, format="PNG")
|
| 28 |
image_data = image_io.getvalue()
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
| 30 |
return {"report": report}
|
|
|
|
| 31 |
except Exception as e:
|
|
|
|
| 32 |
raise HTTPException(status_code=500, detail=str(e))
|
| 33 |
|
| 34 |
|
|
|
|
| 22 |
@app.post("/upload-image/")
|
| 23 |
async def upload_image(file: UploadFile = File(...)):
|
| 24 |
try:
|
| 25 |
+
print(f"β
Received file: {file.filename}")
|
| 26 |
+
|
| 27 |
+
image = await convert_to_png(file) # this may hang
|
| 28 |
+
print(f"β
Image converted to PNG")
|
| 29 |
+
|
| 30 |
image_io = io.BytesIO()
|
| 31 |
image.save(image_io, format="PNG")
|
| 32 |
image_data = image_io.getvalue()
|
| 33 |
+
|
| 34 |
+
report = generate_report(image_data) # this may also hang
|
| 35 |
+
print(f"β
Report generated")
|
| 36 |
+
|
| 37 |
return {"report": report}
|
| 38 |
+
|
| 39 |
except Exception as e:
|
| 40 |
+
print(f"β Error: {str(e)}")
|
| 41 |
raise HTTPException(status_code=500, detail=str(e))
|
| 42 |
|
| 43 |
|