import subprocess import sys import time def main(): print("Starting Finance LLM System in Docker (Hugging Face Mode)...") # Start FastAPI backend internally on port 8000 print("Starting FastAPI Backend...") backend = subprocess.Popen( [sys.executable, "-m", "uvicorn", "src.api.main:app", "--host", "127.0.0.1", "--port", "8000"], ) # Give the backend a moment to start time.sleep(5) # Start Streamlit frontend and bind it to 0.0.0.0 on port 7860 (required by Hugging Face) print("Starting Streamlit Frontend on public port 7860...") frontend = subprocess.Popen( [ sys.executable, "-m", "streamlit", "run", "src/ui/streamlit_app.py", "--server.port", "7860", "--server.address", "0.0.0.0" ] ) try: backend.wait() frontend.wait() except KeyboardInterrupt: backend.terminate() frontend.terminate() if __name__ == "__main__": main()