leavoigt commited on
Commit
ab1a4c9
·
verified ·
1 Parent(s): 7121e85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -22
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
- # Interface
7
- with gr.Blocks() as ui:
 
 
 
 
 
8
 
9
- with gr.Row():
10
- file_input = gr.File(file_types=[".geojson"])
11
 
12
- with gr.Row():
13
- with gr.Column():
14
- submit_btn = gr.Button("Submit")
15
 
16
- with gr.Row():
17
- output = gr.Dataframe()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
 
20
- # Submit button action
21
- submit_btn.click(get_statistics,
22
- file_input, output)
23
 
24
- # Launch app
25
- if __name__ == "__main__":
26
- ui.launch(
27
- server_name="0.0.0.0",
28
- server_port=7860,
29
- #mcp_server=True,
30
- show_error=True
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
+ # )