habulaj commited on
Commit
04ebd2c
·
verified ·
1 Parent(s): 9cd282f

Update routers/profanity.py

Browse files
Files changed (1) hide show
  1. 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
- output_path = f"decoded_{os.urandom(4).hex()}.png"
61
- img.save(output_path)
 
 
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)}")