Spaces:
Runtime error
Runtime error
Commit ·
b0a7802
1
Parent(s): fba2beb
fix: use exec() to run demo app with correct __file__ context
Browse filesCo-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- streamlit_app.py +9 -6
streamlit_app.py
CHANGED
|
@@ -1,9 +1,12 @@
|
|
| 1 |
-
import sys
|
| 2 |
from pathlib import Path
|
| 3 |
|
| 4 |
-
|
| 5 |
-
sys.path.insert(0, str(
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
| 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 |
+
demo = root / "demo" / "streamlit_app.py"
|
| 9 |
+
with open(demo, encoding="utf-8") as f:
|
| 10 |
+
code = f.read()
|
| 11 |
+
|
| 12 |
+
exec(compile(code, str(demo), "exec"), {"__file__": str(demo), "__name__": "__main__"})
|