File size: 2,021 Bytes
95e10ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
54
55
56
57
58
59
60
61
62
63
"""

Startup script for HealthGuard-AI with debugging enabled.

"""

import os
import sys
import subprocess
import signal
import time

def signal_handler(sig, frame):
    """Handle Ctrl+C gracefully."""
    print('\nShutting down gracefully...')
    sys.exit(0)

def main():
    """Main function to start the application with debugging."""
    print("HealthGuard-AI Debug Startup")
    print("=" * 30)
    
    # Set up signal handler for graceful shutdown
    signal.signal(signal.SIGINT, signal_handler)
    
    # Check if we're in the right directory
    if not os.path.exists('app.py'):
        print("Error: app.py not found in current directory")
        print("Please run this script from the HealthGuard-AI directory")
        sys.exit(1)
    
    # Print instructions
    print("Starting HealthGuard-AI with debugging enabled...")
    print("Access the application at: http://localhost:7860")
    print("Debug endpoints:")
    print("  - http://localhost:7860/debug/login-status")
    print("  - http://localhost:7860/debug/test-session")
    print("  - http://localhost:7860/debug/clear-session")
    print("  - http://localhost:7860/debug/user/<email>")
    print("\nPress Ctrl+C to stop the server")
    print("=" * 50)
    
    # Start the Flask application
    try:
        # Set environment variables if not already set
        if not os.getenv('FLASK_APP'):
            os.environ['FLASK_APP'] = 'app.py'
        
        if not os.getenv('FLASK_ENV'):
            os.environ['FLASK_ENV'] = 'development'
        
        # Run the Flask application
        subprocess.run([sys.executable, 'app.py'], check=True)
        
    except subprocess.CalledProcessError as e:
        print(f"Error running the application: {e}")
        sys.exit(1)
    except KeyboardInterrupt:
        print("\nApplication stopped by user")
    except Exception as e:
        print(f"Unexpected error: {e}")
        sys.exit(1)

if __name__ == "__main__":
    main()