richard-su commited on
Commit
6c2f516
·
verified ·
1 Parent(s): 2f74fe7

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +12 -36
app.py CHANGED
@@ -3,7 +3,7 @@
3
  PodcastMcpGradio - Main Entry Point
4
 
5
  This is the main entry point for the PodcastMcpGradio application.
6
- It supports both local and Modal deployment modes.
7
  """
8
 
9
  import os
@@ -13,41 +13,17 @@ import sys
13
  current_dir = os.path.dirname(os.path.abspath(__file__))
14
  sys.path.insert(0, current_dir)
15
 
16
- # Detect environment early
17
- is_hf_spaces = "SPACE_ID" in os.environ
 
18
 
19
- # Initialize app variable at module level
20
- app = None
21
 
22
- if is_hf_spaces:
23
- # HF Spaces mode: Set environment and create app
24
- print("🤗 Detected HF Spaces environment")
25
- os.environ["DEPLOYMENT_MODE"] = "local"
26
- os.environ["HF_SPACES_MODE"] = "1" # Flag to prevent uvicorn
27
-
28
- # Import and create app directly
29
- from src.app import create_app
30
- app = create_app()
31
- print("✅ App created for HF Spaces")
32
 
33
- else:
34
- # For other environments
35
- from src.app import create_app, main, get_app
36
-
37
- # Re-export for compatibility
38
- __all__ = ["create_app", "main", "get_app", "app"]
39
-
40
- if __name__ == "__main__":
41
- # Local development mode: use uvicorn
42
- print("🏠 Local development mode")
43
- from src.app import run_local
44
- run_local()
45
- else:
46
- # Other environments
47
- app = get_app()
48
-
49
- # Ensure app is always defined at module level for HF Spaces
50
- if app is None and not __name__ == "__main__":
51
- print("⚠️ Creating fallback app")
52
- from src.app import get_app
53
- app = get_app()
 
3
  PodcastMcpGradio - Main Entry Point
4
 
5
  This is the main entry point for the PodcastMcpGradio application.
6
+ Simplified for Hugging Face Spaces deployment.
7
  """
8
 
9
  import os
 
13
  current_dir = os.path.dirname(os.path.abspath(__file__))
14
  sys.path.insert(0, current_dir)
15
 
16
+ # Set environment for HF Spaces
17
+ os.environ.setdefault("DEPLOYMENT_MODE", "local")
18
+ os.environ.setdefault("HF_SPACES_MODE", "1")
19
 
20
+ # Import and create app
21
+ from src.app import create_app, run_local
22
 
23
+ # Create app instance
24
+ app = create_app()
 
 
 
 
 
 
 
 
25
 
26
+ if __name__ == "__main__":
27
+ # Run the application
28
+ print("🚀 Starting PodcastMcpGradio application")
29
+ run_local()