Update app.py
Browse files
app.py
CHANGED
|
@@ -468,19 +468,22 @@ def gradio_process(input_mode, uploads, path_in, drive_url,
|
|
| 468 |
fig.savefig(filename)
|
| 469 |
gallery_images.append(filename)
|
| 470 |
|
| 471 |
-
|
| 472 |
final_paths = output_paths
|
| 473 |
if zip_enable:
|
| 474 |
if input_mode == "Path" and path_in.strip():
|
| 475 |
base = os.path.basename(path_in.rstrip("/"))
|
| 476 |
else:
|
| 477 |
base = os.path.splitext(os.path.basename(inputs[0]))[0] if inputs else "exported"
|
| 478 |
-
zip_path = os.path.join(OUTPUT_DIR, f"{base}.zip")
|
| 479 |
-
with zipfile.ZipFile(zip_path, 'w') as
|
| 480 |
-
for
|
| 481 |
-
|
|
|
|
| 482 |
final_paths = [zip_path]
|
| 483 |
-
logs.append(f"
|
|
|
|
|
|
|
| 484 |
|
| 485 |
# === Exported Files Summary & Settings Echo ===
|
| 486 |
logs.append("=== Exported Files ===")
|
|
|
|
| 468 |
fig.savefig(filename)
|
| 469 |
gallery_images.append(filename)
|
| 470 |
|
| 471 |
+
# === Handle ZIP option ===
|
| 472 |
final_paths = output_paths
|
| 473 |
if zip_enable:
|
| 474 |
if input_mode == "Path" and path_in.strip():
|
| 475 |
base = os.path.basename(path_in.rstrip("/"))
|
| 476 |
else:
|
| 477 |
base = os.path.splitext(os.path.basename(inputs[0]))[0] if inputs else "exported"
|
| 478 |
+
zip_path = os.path.join(OUTPUT_DIR, f"{base}_processed.zip")
|
| 479 |
+
with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
| 480 |
+
for file in output_paths:
|
| 481 |
+
arcname = os.path.basename(file)
|
| 482 |
+
zipf.write(file, arcname=arcname)
|
| 483 |
final_paths = [zip_path]
|
| 484 |
+
logs.append(f"📦 Exported all outputs into ZIP: {os.path.basename(zip_path)}")
|
| 485 |
+
|
| 486 |
+
return "\n".join(logs), final_paths, gallery_images
|
| 487 |
|
| 488 |
# === Exported Files Summary & Settings Echo ===
|
| 489 |
logs.append("=== Exported Files ===")
|