File size: 1,411 Bytes
e0ef700
 
 
 
 
 
 
 
 
 
 
e1cd12d
 
 
 
 
 
 
 
 
 
 
 
 
e7e3a78
e0ef700
 
e7e3a78
 
 
 
 
 
 
 
e0ef700
e7e3a78
 
 
 
 
 
e0ef700
f00b2e2
 
e0ef700
f00b2e2
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
#!/usr/bin/env python3
"""
HuggingFace Spaces entry point for Ideal Polyhedron Volume Toolkit.

This file is the entry point for HuggingFace Spaces deployment.
HF Spaces automatically runs app.py and calls demo.launch().
"""

import os
import sys

# Debug: print versions before anything else
try:
    import gradio
    print(f"Gradio version: {gradio.__version__}")
except Exception as e:
    print(f"Could not import gradio: {e}")

try:
    import huggingface_hub
    print(f"HuggingFace Hub version: {huggingface_hub.__version__}")
except Exception as e:
    print(f"Could not import huggingface_hub: {e}")

# Add the repo root to path so imports work
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

try:
    from bin.gui import create_gui
    demo = create_gui()
    print("Successfully loaded Ideal Polyhedron Volume Toolkit GUI")
except Exception as e:
    # Fallback: show error in a simple Gradio interface
    import gradio as gr
    import traceback

    error_msg = f"Failed to load the main GUI:\n\n{str(e)}\n\n{traceback.format_exc()}"
    print(error_msg)

    with gr.Blocks() as demo:
        gr.Markdown("# Error Loading Application")
        gr.Markdown(f"```\n{error_msg}\n```")

# For Docker SDK on HF Spaces, we must explicitly launch
# with server_name="0.0.0.0" to bind to all interfaces
if __name__ == "__main__":
    demo.launch(server_name="0.0.0.0", server_port=7860)