Spaces:
Runtime error
Runtime error
Commit ·
e247c59
1
Parent(s): b0a7802
fix: catch startup errors and display them instead of crash-looping
Browse files- streamlit_app.py +10 -6
streamlit_app.py
CHANGED
|
@@ -1,12 +1,16 @@
|
|
| 1 |
-
import sys, os
|
|
|
|
| 2 |
from pathlib import Path
|
| 3 |
|
| 4 |
root = Path(__file__).resolve().parent
|
| 5 |
sys.path.insert(0, str(root))
|
| 6 |
os.chdir(str(root))
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
exec(compile(code, str(demo), "exec"), {"__file__": str(demo), "__name__": "__main__"})
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys, os, traceback
|
| 2 |
+
import streamlit as st
|
| 3 |
from pathlib import Path
|
| 4 |
|
| 5 |
root = Path(__file__).resolve().parent
|
| 6 |
sys.path.insert(0, str(root))
|
| 7 |
os.chdir(str(root))
|
| 8 |
|
| 9 |
+
try:
|
| 10 |
+
demo = root / "demo" / "streamlit_app.py"
|
| 11 |
+
with open(demo, encoding="utf-8") as f:
|
| 12 |
+
code = f.read()
|
| 13 |
+
exec(compile(code, str(demo), "exec"), {"__file__": str(demo), "__name__": "__main__"})
|
| 14 |
+
except Exception as e:
|
| 15 |
+
st.error(f"App failed to load: {e}")
|
| 16 |
+
st.code(traceback.format_exc())
|