Update routers/profanity.py
Browse files- routers/profanity.py +6 -7
routers/profanity.py
CHANGED
@@ -57,13 +57,12 @@ def decode_custom(code: str = Query(...)):
|
|
57 |
img = Image.new("RGB", (width, height))
|
58 |
img.putdata(pixels)
|
59 |
|
60 |
-
|
61 |
-
|
|
|
|
|
62 |
|
63 |
-
return
|
64 |
-
"message": "Image decoded successfully.",
|
65 |
-
"output_file": output_path
|
66 |
-
}
|
67 |
|
68 |
except Exception as e:
|
69 |
-
raise HTTPException(status_code=500, detail=str(e))
|
|
|
57 |
img = Image.new("RGB", (width, height))
|
58 |
img.putdata(pixels)
|
59 |
|
60 |
+
# Em vez de salvar no disco, envia direto na resposta
|
61 |
+
buffer = BytesIO()
|
62 |
+
img.save(buffer, format="PNG")
|
63 |
+
buffer.seek(0)
|
64 |
|
65 |
+
return StreamingResponse(buffer, media_type="image/png")
|
|
|
|
|
|
|
66 |
|
67 |
except Exception as e:
|
68 |
+
raise HTTPException(status_code=500, detail=f"Decoding failed: {str(e)}")
|