File size: 916 Bytes
9b87eaa
e0637d2
9b87eaa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e0637d2
 
 
 
 
 
 
 
 
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
import importlib
import gradio as gr

_module = importlib.import_module('app_claude_41')

# Expose a Gradio Blocks/Interface as `demo` at module scope for Spaces
# Try common names or build via factory

demo = None
for attr_name in ('demo', 'app', 'iface', 'interface'):
    if hasattr(_module, attr_name):
        demo = getattr(_module, attr_name)
        break

if demo is None:
    for factory_name in ('create_demo', 'build_demo', 'get_demo'):
        if hasattr(_module, factory_name):
            demo = getattr(_module, factory_name)()
            break

# Ultimate fallback to avoid uninitialized app in Spaces
if demo is None:
    def _fallback_echo(text: str) -> str:
        return f"Fallback active. Received: {text}"

    demo = gr.Interface(fn=_fallback_echo, inputs=gr.Textbox(label='Input'), outputs=gr.Textbox(label='Output'), title='Fallback Demo')

if __name__ == '__main__':
    demo.launch()