Create streamlit_app.py
Browse files- src/streamlit_app.py +20 -0
src/streamlit_app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os, types, streamlit as st
|
2 |
+
import os
|
3 |
+
os.environ['STREAMLIT_CONFIG_DIR'] = '/tmp/.streamlit'
|
4 |
+
# Fetch the hidden code from env var
|
5 |
+
app_code = os.environ.get("APP_CODE", "")
|
6 |
+
|
7 |
+
def execute_code(code_str):
|
8 |
+
module = types.ModuleType("dynamic_app")
|
9 |
+
try:
|
10 |
+
exec(code_str, module.__dict__)
|
11 |
+
if hasattr(module, "main"):
|
12 |
+
module.main()
|
13 |
+
except Exception as e:
|
14 |
+
st.error(f"Error in hidden code: {e}")
|
15 |
+
|
16 |
+
if app_code:
|
17 |
+
execute_code(app_code)
|
18 |
+
|
19 |
+
else:
|
20 |
+
st.error("APP_CODE is empty. Did you set it?")
|