igriv commited on
Commit
e7e3a78
·
1 Parent(s): e0ef700

Add error handling to app.py for debugging HF Spaces

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -9,13 +9,24 @@ HF Spaces automatically runs app.py and calls demo.launch().
9
  import os
10
  import sys
11
 
12
- # Add bin directory to path so we can import gui module
13
  sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
14
 
15
- from bin.gui import create_gui
 
 
 
 
 
 
 
16
 
17
- # Create the Gradio demo
18
- demo = create_gui()
 
 
 
 
19
 
20
  # HuggingFace Spaces will call demo.launch() automatically,
21
  # but we can also run this directly for testing
 
9
  import os
10
  import sys
11
 
12
+ # Add the repo root to path so imports work
13
  sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
14
 
15
+ try:
16
+ from bin.gui import create_gui
17
+ demo = create_gui()
18
+ print("Successfully loaded Ideal Polyhedron Volume Toolkit GUI")
19
+ except Exception as e:
20
+ # Fallback: show error in a simple Gradio interface
21
+ import gradio as gr
22
+ import traceback
23
 
24
+ error_msg = f"Failed to load the main GUI:\n\n{str(e)}\n\n{traceback.format_exc()}"
25
+ print(error_msg)
26
+
27
+ with gr.Blocks() as demo:
28
+ gr.Markdown("# Error Loading Application")
29
+ gr.Markdown(f"```\n{error_msg}\n```")
30
 
31
  # HuggingFace Spaces will call demo.launch() automatically,
32
  # but we can also run this directly for testing