#!/usr/bin/env python3 """ LandPPT Application Runner This script starts the LandPPT FastAPI application with proper configuration. """ import uvicorn import sys import os from dotenv import load_dotenv # Add src to Python path sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) # Load environment variables with error handling try: load_dotenv() except PermissionError as e: print(f"Warning: Could not load .env file due to permission error: {e}") print("Continuing with system environment variables...") except Exception as e: print(f"Warning: Could not load .env file: {e}") print("Continuing with system environment variables...") def main(): """Main entry point for running the application""" # Get configuration from environment variables with defaults host = os.getenv("HOST", "0.0.0.0") port = int(os.getenv("PORT", "8000")) reload = os.getenv("RELOAD", "true").lower() in ("true", "1", "yes", "on") log_level = os.getenv("LOG_LEVEL", "info").lower() # Configuration config = { "app": "landppt.main:app", "host": host, "port": port, "reload": reload, "log_level": log_level, "access_log": True, } print("šŸš€ Starting LandPPT Server...") print(f"šŸ“ Host: {config['host']}") print(f"šŸ”Œ Port: {config['port']}") print(f"šŸ”„ Reload: {config['reload']}") print(f"šŸ“Š Log Level: {config['log_level']}") print(f"šŸ“ Server will be available at: http://localhost:{config['port']}") print(f"šŸ“š API Documentation: http://localhost:{config['port']}/docs") print(f"🌐 Web Interface: http://localhost:{config['port']}/web") print("=" * 60) try: uvicorn.run(**config) except KeyboardInterrupt: print("\nšŸ‘‹ Server stopped by user") except Exception as e: print(f"āŒ Error starting server: {e}") sys.exit(1) if __name__ == "__main__": main()