#!/usr/bin/env python3 """ Startup script for TradingAgents Web Application Backend """ import os import sys import subprocess def main(): # Change to backend directory backend_dir = os.path.dirname(os.path.abspath(__file__)) backend_dir = os.path.join(backend_dir, 'backend') print("šŸš€ Starting TradingAgents Web Application Backend") print(f"šŸ“ Backend directory: {backend_dir}") # Check if main.py exists main_py = os.path.join(backend_dir, 'main.py') if not os.path.exists(main_py): print(f"āŒ main.py not found at {main_py}") return False # Change to backend directory and run os.chdir(backend_dir) print("šŸ”§ Installing dependencies...") try: subprocess.run([sys.executable, '-m', 'pip', 'install', 'fastapi', 'uvicorn', 'pydantic', 'python-multipart'], check=True, capture_output=True) print("āœ… Dependencies installed") except subprocess.CalledProcessError as e: print(f"āš ļø Warning: Could not install dependencies: {e}") print(" Please install manually: pip install fastapi uvicorn pydantic python-multipart") print("🌐 Starting FastAPI server...") print(" Server will be available at: http://localhost:8000") print(" API documentation at: http://localhost:8000/docs") print(" Press Ctrl+C to stop the server") print("-" * 50) try: # Run the server subprocess.run([sys.executable, 'main.py'], check=True) except KeyboardInterrupt: print("\nšŸ›‘ Server stopped by user") except subprocess.CalledProcessError as e: print(f"āŒ Server failed to start: {e}") return False return True if __name__ == "__main__": main()