From 0f46996c85767c91a17cc0016e7a2a1010717447 Mon Sep 17 00:00:00 2001 From: MarkLo Date: Thu, 20 Nov 2025 22:40:07 +0800 Subject: [PATCH] --- backend/__main__.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 backend/__main__.py diff --git a/backend/__main__.py b/backend/__main__.py new file mode 100644 index 00000000..5dedfa83 --- /dev/null +++ b/backend/__main__.py @@ -0,0 +1,41 @@ +""" +Backend module entry point +Run with: python -m backend +""" +import uvicorn +import os +import sys +from pathlib import Path + +# Add parent directory to path to import tradingagents +parent_dir = str(Path(__file__).parent.parent) +if parent_dir not in sys.path: + sys.path.insert(0, parent_dir) + + +def main(): + """Start the FastAPI server""" + # Get host and port from environment variables with defaults + host = os.getenv("BACKEND_HOST", "0.0.0.0") + port = int(os.getenv("BACKEND_PORT", "8000")) + reload = os.getenv("BACKEND_RELOAD", "true").lower() == "true" + + print(f"šŸš€ Starting TradingAgents Backend Server...") + print(f"šŸ“ Host: {host}") + print(f"šŸ”Œ Port: {port}") + print(f"šŸ”„ Reload: {reload}") + print(f"\nšŸ“– API Documentation: http://{host}:{port}/docs") + print(f"šŸ“Š Health Check: http://{host}:{port}/api/health\n") + + # Start uvicorn server + uvicorn.run( + "app.main:app", + host=host, + port=port, + reload=reload, + log_level="info", + ) + + +if __name__ == "__main__": + main()