Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,56 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
-
import json
|
3 |
-
from utils.main_processor import get_statistics
|
4 |
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
|
24 |
-
# Launch app
|
25 |
-
if __name__ == "__main__":
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
1 |
+
import subprocess
|
2 |
+
from pathlib import Path
|
3 |
import gradio as gr
|
|
|
|
|
4 |
|
5 |
+
FREEZE_FILE = "requirements_full.txt"
|
6 |
|
7 |
+
def dump_installed_packages():
|
8 |
+
"""Generate the list of installed packages into a file."""
|
9 |
+
try:
|
10 |
+
with open(FREEZE_FILE, "w") as f:
|
11 |
+
subprocess.run(["pip", "freeze"], stdout=f, check=True)
|
12 |
+
except Exception as e:
|
13 |
+
print(f"[ERROR] Could not write requirements: {e}")
|
14 |
|
15 |
+
# Generate it once at runtime
|
16 |
+
dump_installed_packages()
|
17 |
|
18 |
+
with gr.Blocks() as demo:
|
19 |
+
gr.Markdown("📦 Download the list of installed Python packages:")
|
20 |
+
gr.File(value=FREEZE_FILE, label="requirements_full.txt")
|
21 |
|
22 |
+
# IMPORTANT: This is required in Hugging Face Spaces using Docker
|
23 |
+
if __name__ == "__main__":
|
24 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, mcp_server=True)
|
25 |
+
|
26 |
+
# import gradio as gr
|
27 |
+
# import json
|
28 |
+
# from utils.main_processor import get_statistics
|
29 |
+
|
30 |
+
|
31 |
+
# # Interface
|
32 |
+
# with gr.Blocks() as ui:
|
33 |
+
|
34 |
+
# with gr.Row():
|
35 |
+
# file_input = gr.File(file_types=[".geojson"])
|
36 |
+
|
37 |
+
# with gr.Row():
|
38 |
+
# with gr.Column():
|
39 |
+
# submit_btn = gr.Button("Submit")
|
40 |
+
|
41 |
+
# with gr.Row():
|
42 |
+
# output = gr.Dataframe()
|
43 |
|
44 |
|
45 |
+
# # Submit button action
|
46 |
+
# submit_btn.click(get_statistics,
|
47 |
+
# file_input, output)
|
48 |
|
49 |
+
# # Launch app
|
50 |
+
# if __name__ == "__main__":
|
51 |
+
# ui.launch(
|
52 |
+
# server_name="0.0.0.0",
|
53 |
+
# server_port=7860,
|
54 |
+
# #mcp_server=True,
|
55 |
+
# show_error=True
|
56 |
+
# )
|