import streamlit as st import os import sys from tempfile import NamedTemporaryFile import traceback def main(): st.set_page_config( page_title="ACE Singer", page_icon="🎵", layout="wide" ) st.title("🎵 ACE Singer") try: # Get the code from environment variables code = os.environ.get("MAIN_CODE") if not code: st.error("⚠️ The application code wasn't found in environment variables. Please add the MAIN_CODE.") st.info("Please set the MAIN_CODE environment variable with your application code.") return st.success("✅ Application code loaded successfully!") # Execute the code in a controlled way exec_globals = { '__name__': '__main__', 'st': st, 'os': os, 'sys': sys } exec(compile(code, '', 'exec'), exec_globals) except Exception as e: st.error(f"⚠️ Error loading or executing the application: {str(e)}") with st.expander("Show detailed error"): st.code(traceback.format_exc()) if __name__ == "__main__": main()