""" 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/") 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()