File size: 1,004 Bytes
4024eae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
AI Newsletter Generator - Hugging Face Spaces Entry Point

This file serves as an alternative entry point for Hugging Face Spaces.
The main application is in backend/main.py and runs via uvicorn.
"""

import subprocess
import sys
import os

def main():
    """Start the FastAPI application for Hugging Face Spaces"""
    
    # Set default port for Hugging Face Spaces
    port = os.getenv("PORT", "7860")
    
    # Command to start the FastAPI app
    cmd = [
        sys.executable, "-m", "uvicorn", 
        "backend.main:app", 
        "--host", "0.0.0.0", 
        "--port", port
    ]
    
    print(f"Starting AI Newsletter Generator on port {port}...")
    print(f"Command: {' '.join(cmd)}")
    
    try:
        subprocess.run(cmd, check=True)
    except KeyboardInterrupt:
        print("\nShutting down...")
    except subprocess.CalledProcessError as e:
        print(f"Error starting application: {e}")
        sys.exit(1)

if __name__ == "__main__":
    main()