Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,32 @@
|
|
|
|
1 |
import shutil
|
2 |
import os
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
import shutil
|
3 |
import os
|
4 |
+
import csv
|
5 |
|
6 |
+
# CSV ํ๋ ํฌ๊ธฐ ์ ํ ๋๋ฆฌ๊ธฐ
|
7 |
+
csv.field_size_limit(10**6)
|
8 |
+
|
9 |
+
# ์บ์ ํ์ผ ์ญ์ ํจ์
|
10 |
+
def clear_cache():
|
11 |
+
cache_dir_14 = "/home/user/app/gradio_cached_examples/14"
|
12 |
+
cache_dir_28 = "/home/user/app/gradio_cached_examples/28"
|
13 |
+
|
14 |
+
removed_dirs = []
|
15 |
+
for cache_dir in [cache_dir_14, cache_dir_28]:
|
16 |
+
if os.path.exists(cache_dir):
|
17 |
+
shutil.rmtree(cache_dir)
|
18 |
+
removed_dirs.append(f"{cache_dir} has been removed.")
|
19 |
+
else:
|
20 |
+
removed_dirs.append(f"{cache_dir} does not exist.")
|
21 |
+
return "\n".join(removed_dirs)
|
22 |
+
|
23 |
+
# Gradio ์ธํฐํ์ด์ค
|
24 |
+
with gr.Blocks() as demo:
|
25 |
+
gr.Markdown("## Gradio Cache Cleaner")
|
26 |
+
clear_button = gr.Button("Clear Cache")
|
27 |
+
output = gr.Textbox()
|
28 |
+
|
29 |
+
clear_button.click(fn=clear_cache, outputs=output)
|
30 |
+
|
31 |
+
if __name__ == "__main__":
|
32 |
+
demo.launch()
|