Spaces:
Paused
Paused
giorgio-caparvi
commited on
Commit
·
63a4201
1
Parent(s):
e8fb341
saving image and then return response
Browse files- api/app.py +7 -4
api/app.py
CHANGED
@@ -85,15 +85,18 @@ def generate_design():
|
|
85 |
for file_name in os.listdir(os.getcwd()):
|
86 |
print(file_name)
|
87 |
|
|
|
|
|
|
|
88 |
# Also save the image to a BytesIO buffer to return via HTTP
|
89 |
-
img_io = io.BytesIO()
|
90 |
-
final_image.save(img_io, 'JPEG')
|
91 |
-
img_io.seek(0)
|
92 |
|
93 |
|
94 |
|
95 |
# Return the image as a file download
|
96 |
-
return send_file(img_io, mimetype='image/jpeg', as_attachment=True, download_name='generated_image.jpg')
|
97 |
|
98 |
except Exception as e:
|
99 |
return str(e), 500
|
|
|
85 |
for file_name in os.listdir(os.getcwd()):
|
86 |
print(file_name)
|
87 |
|
88 |
+
# Invia l'immagine come file scaricabile direttamente dalla directory
|
89 |
+
return send_file(save_path, mimetype='image/jpeg', as_attachment=True)
|
90 |
+
|
91 |
# Also save the image to a BytesIO buffer to return via HTTP
|
92 |
+
#img_io = io.BytesIO()
|
93 |
+
#final_image.save(img_io, 'JPEG')
|
94 |
+
#img_io.seek(0)
|
95 |
|
96 |
|
97 |
|
98 |
# Return the image as a file download
|
99 |
+
#return send_file(img_io, mimetype='image/jpeg', as_attachment=True, download_name='generated_image.jpg')
|
100 |
|
101 |
except Exception as e:
|
102 |
return str(e), 500
|