Spaces:
Running
on
Zero
Running
on
Zero
wjm55
commited on
Commit
·
cf99179
1
Parent(s):
266e1d2
trying to fix download
Browse files
app.py
CHANGED
@@ -301,16 +301,18 @@ with gr.Blocks(css=css) as demo:
|
|
301 |
with open(json_path, 'w', encoding='utf-8') as f:
|
302 |
json.dump(json_data, f, indent=2, ensure_ascii=False)
|
303 |
|
304 |
-
# Create zip file
|
305 |
-
|
|
|
|
|
|
|
306 |
with zipfile.ZipFile(zip_path, 'w') as zipf:
|
307 |
zipf.write(img_path, os.path.basename(img_path))
|
308 |
zipf.write(txt_path, os.path.basename(txt_path))
|
309 |
zipf.write(json_path, os.path.basename(json_path))
|
310 |
|
311 |
-
#
|
312 |
-
|
313 |
-
return (f"{fname}.zip", f.read())
|
314 |
except Exception as e:
|
315 |
print(f"Error creating zip: {str(e)}")
|
316 |
return None
|
|
|
301 |
with open(json_path, 'w', encoding='utf-8') as f:
|
302 |
json.dump(json_data, f, indent=2, ensure_ascii=False)
|
303 |
|
304 |
+
# Create zip file in a location that will persist
|
305 |
+
output_dir = "downloads"
|
306 |
+
os.makedirs(output_dir, exist_ok=True)
|
307 |
+
zip_path = os.path.join(output_dir, f"{fname}.zip")
|
308 |
+
|
309 |
with zipfile.ZipFile(zip_path, 'w') as zipf:
|
310 |
zipf.write(img_path, os.path.basename(img_path))
|
311 |
zipf.write(txt_path, os.path.basename(txt_path))
|
312 |
zipf.write(json_path, os.path.basename(json_path))
|
313 |
|
314 |
+
return zip_path # Return just the path to the zip file
|
315 |
+
|
|
|
316 |
except Exception as e:
|
317 |
print(f"Error creating zip: {str(e)}")
|
318 |
return None
|