Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Add error handling to app.py for debugging HF Spaces
Browse files
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
|
| 13 |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|