| 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?") | |