File size: 540 Bytes
7a0f24e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os, types, streamlit as st
import os
os.environ['STREAMLIT_CONFIG_DIR'] = '/tmp/.streamlit'
# Fetch the hidden code from env var
app_code = os.environ.get("APP_CODE", "")

def execute_code(code_str):
    module = types.ModuleType("dynamic_app")
    try:
        exec(code_str, module.__dict__)
        if hasattr(module, "main"):
            module.main()
    except Exception as e:
        st.error(f"Error in hidden code: {e}")

if app_code:
    execute_code(app_code)
    
else:
    st.error("APP_CODE is empty. Did you set it?")