Spaces:
Sleeping
Sleeping
fixed zip file issue
Browse files
app.py
CHANGED
|
@@ -2,6 +2,8 @@ import io
|
|
| 2 |
import zipfile
|
| 3 |
import json
|
| 4 |
import time
|
|
|
|
|
|
|
| 5 |
from PIL import Image
|
| 6 |
import gradio as gr
|
| 7 |
|
|
@@ -136,7 +138,14 @@ def gradio_ui(image, name, short_name, theme_color, background_color, tile_color
|
|
| 136 |
if result is None:
|
| 137 |
return None
|
| 138 |
filename, zip_buf = result
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
demo = gr.Interface(
|
| 142 |
fn=gradio_ui,
|
|
@@ -154,4 +163,4 @@ demo = gr.Interface(
|
|
| 154 |
)
|
| 155 |
|
| 156 |
if __name__ == "__main__":
|
| 157 |
-
demo.launch(debug=True, pwa=True)
|
|
|
|
| 2 |
import zipfile
|
| 3 |
import json
|
| 4 |
import time
|
| 5 |
+
import tempfile
|
| 6 |
+
import os
|
| 7 |
from PIL import Image
|
| 8 |
import gradio as gr
|
| 9 |
|
|
|
|
| 138 |
if result is None:
|
| 139 |
return None
|
| 140 |
filename, zip_buf = result
|
| 141 |
+
|
| 142 |
+
# Save ZIP to temporary file for Gradio download
|
| 143 |
+
tmp_dir = tempfile.mkdtemp()
|
| 144 |
+
filepath = os.path.join(tmp_dir, filename)
|
| 145 |
+
with open(filepath, "wb") as f:
|
| 146 |
+
f.write(zip_buf.read())
|
| 147 |
+
|
| 148 |
+
return filepath
|
| 149 |
|
| 150 |
demo = gr.Interface(
|
| 151 |
fn=gradio_ui,
|
|
|
|
| 163 |
)
|
| 164 |
|
| 165 |
if __name__ == "__main__":
|
| 166 |
+
demo.launch(server_host="0.0.0.0", server_port=7860, debug=True, pwa=True)
|