File size: 995 Bytes
f492e79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import sys

def main():
    try:
        # Get the code from secrets
        code = os.environ.get("MAIN_CODE")
        
        if not code:
            # Fallback: create a simple error display
            import gradio as gr
            with gr.Blocks() as demo:
                gr.Markdown("# ⚠️ Error")
                gr.Markdown("The application code wasn't found in secrets. Please add the MAIN_CODE secret.")
            demo.launch()
            return
        
        # Execute the code directly
        exec(compile(code, '<string>', 'exec'), globals())
        
    except Exception as e:
        import gradio as gr
        import traceback
        error_msg = traceback.format_exc()
        
        with gr.Blocks() as demo:
            gr.Markdown("# ⚠️ Error Loading Application")
            gr.Markdown(f"**Error:** {str(e)}")
            gr.Code(error_msg, language="python", label="Traceback")
        demo.launch()

if __name__ == "__main__":
    main()