blogger / app.py
ginipick's picture
Update app.py
f025afc verified
raw
history blame
728 Bytes
import streamlit as st
import os
import base64
import types
# Secretμ—μ„œ μ €μž₯된 μ½”λ“œ κ°€μ Έμ˜€κΈ°
app_code = os.environ.get("APP", "")
# μ½”λ“œ μ‹€ν–‰ ν•¨μˆ˜
def execute_code(code_str):
try:
# μ‹€ν–‰ κ°€λŠ₯ν•œ μ½”λ“œλ‘œ λ³€ν™˜
code_module = types.ModuleType('dynamic_code')
exec(code_str, code_module.__dict__)
# ν•„μš”ν•œ ν•¨μˆ˜ μ‹€ν–‰
if hasattr(code_module, 'main'):
code_module.main()
except Exception as e:
st.error(f"μ½”λ“œ μ‹€ν–‰ 쀑 였λ₯˜ λ°œμƒ: {str(e)}")
# μ½”λ“œ μ‹€ν–‰
if app_code:
execute_code(app_code)
else:
st.error("μ½”λ“œλ₯Ό 뢈러올 수 μ—†μŠ΅λ‹ˆλ‹€. Secret이 μ˜¬λ°”λ₯΄κ²Œ μ„€μ •λ˜μ—ˆλŠ”μ§€ ν™•μΈν•˜μ„Έμš”.")