File size: 1,477 Bytes
ab1a4c9
 
ec765f7
 
ab1a4c9
ca823ee
ab1a4c9
 
 
 
 
 
 
e93edee
ab1a4c9
 
7121e85
ab1a4c9
 
 
7121e85
ab1a4c9
 
b11b7b4
 
 
ab1a4c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3563d85
a576faa
ab1a4c9
 
 
ec765f7
ab1a4c9
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import subprocess
from pathlib import Path
import gradio as gr

FREEZE_FILE = "requirements_full.txt"

def dump_installed_packages():
    """Generate the list of installed packages into a file."""
    try:
        with open(FREEZE_FILE, "w") as f:
            subprocess.run(["pip", "freeze"], stdout=f, check=True)
    except Exception as e:
        print(f"[ERROR] Could not write requirements: {e}")

# Generate it once at runtime
dump_installed_packages()

with gr.Blocks() as demo:
    gr.Markdown("📦 Download the list of installed Python packages:")
    gr.File(value=FREEZE_FILE, label="requirements_full.txt")

# IMPORTANT: This is required in Hugging Face Spaces using Docker
if __name__ == "__main__":
    demo.launch(server_name="0.0.0.0", server_port=7860, 
                #mcp_server=True
               )
    
# import gradio as gr
# import json
# from utils.main_processor import get_statistics


# # Interface
# with gr.Blocks() as ui:

#     with gr.Row():
#         file_input = gr.File(file_types=[".geojson"])

#     with gr.Row():
#         with gr.Column():
#             submit_btn = gr.Button("Submit")

#     with gr.Row():
#             output = gr.Dataframe()

    
#     # Submit button action
#     submit_btn.click(get_statistics, 
#     file_input, output)

# # Launch app
# if __name__ == "__main__":
#     ui.launch(
#         server_name="0.0.0.0",
#         server_port=7860, 
#         #mcp_server=True,
#         show_error=True
#     )