Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -722,14 +722,38 @@ with gr.Blocks(css=css) as demo:
|
|
| 722 |
)
|
| 723 |
|
| 724 |
clear_btn.click(
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 733 |
|
| 734 |
stop_btn.click(
|
| 735 |
fn=lambda: "🛑 Stop signal sent",
|
|
|
|
| 722 |
)
|
| 723 |
|
| 724 |
clear_btn.click(
|
| 725 |
+
fn=clear_all, # Python: deletes temp folder & resets all Gradio components
|
| 726 |
+
inputs=[temp_dir_state],
|
| 727 |
+
outputs=[
|
| 728 |
+
workbook_upload,
|
| 729 |
+
image_data_state,
|
| 730 |
+
upload_box,
|
| 731 |
+
zip_file_hidden,
|
| 732 |
+
single_downloads,
|
| 733 |
+
status,
|
| 734 |
+
temp_dir_state,
|
| 735 |
+
image_url_input
|
| 736 |
+
],
|
| 737 |
+
js="""
|
| 738 |
+
// 1) Clear all browser storage
|
| 739 |
+
localStorage.clear();
|
| 740 |
+
sessionStorage.clear();
|
| 741 |
+
|
| 742 |
+
// 2) Purge any ServiceWorker caches
|
| 743 |
+
if ('caches' in window) {
|
| 744 |
+
caches.keys().then(keys => {
|
| 745 |
+
keys.forEach(key => caches.delete(key));
|
| 746 |
+
});
|
| 747 |
+
}
|
| 748 |
+
|
| 749 |
+
// 3) Scroll the status box back to the top
|
| 750 |
+
const el = document.getElementById('status-box');
|
| 751 |
+
if (el) { el.scrollTop = 0; }
|
| 752 |
+
|
| 753 |
+
return [];
|
| 754 |
+
"""
|
| 755 |
+
)
|
| 756 |
+
|
| 757 |
|
| 758 |
stop_btn.click(
|
| 759 |
fn=lambda: "🛑 Stop signal sent",
|