File size: 1,472 Bytes
a902f46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f46e38
 
a902f46
47ac1a7
 
 
0f46e38
47ac1a7
0f46e38
 
 
 
 
 
 
 
a902f46
0f46e38
 
 
 
 
 
 
 
 
 
 
 
 
 
47ac1a7
 
 
 
 
 
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
"""
PodcastMcpGradio - Main Entry Point

This is the main entry point for the PodcastMcpGradio application.
It supports both local and Modal deployment modes.
"""

import os
import sys

# Add current directory to path for src imports
current_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, current_dir)

# Detect environment early
is_hf_spaces = "SPACE_ID" in os.environ

# Initialize app variable at module level
app = None

if is_hf_spaces:
    # HF Spaces mode: Set environment and create app
    print("🤗 Detected HF Spaces environment")
    os.environ["DEPLOYMENT_MODE"] = "local"
    os.environ["HF_SPACES_MODE"] = "1"  # Flag to prevent uvicorn
    
    # Import and create app directly
    from src.app import create_app
    app = create_app()
    print("✅ App created for HF Spaces")

else:
    # For other environments
    from src.app import create_app, main, get_app
    
    # Re-export for compatibility
    __all__ = ["create_app", "main", "get_app", "app"]
    
    if __name__ == "__main__":
        # Local development mode: use uvicorn
        print("🏠 Local development mode")
        from src.app import run_local
        run_local()
    else:
        # Other environments
        app = get_app()

# Ensure app is always defined at module level for HF Spaces
if app is None and not __name__ == "__main__":
    print("⚠️ Creating fallback app")
    from src.app import get_app
    app = get_app()