forked from 0xemmkty/QuantMuse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_web_interface.py
More file actions
71 lines (59 loc) · 2.2 KB
/
run_web_interface.py
File metadata and controls
71 lines (59 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
"""
Trading System Web Interface Launcher
Run this script to start the FastAPI web server with frontend
"""
import subprocess
import sys
import os
import webbrowser
import time
import threading
def main():
"""Launch the web interface"""
print("🚀 Starting Trading System Web Interface...")
print("📊 Web interface will be available at http://localhost:8000")
print("⏹️ Press Ctrl+C to stop the server")
print("-" * 50)
# Get the directory of this script
script_dir = os.path.dirname(os.path.abspath(__file__))
# Set up environment
os.environ['PYTHONPATH'] = script_dir
try:
# Start the FastAPI server
server_process = subprocess.Popen([
sys.executable, "-m", "uvicorn",
"data_service.web.api_server:APIServer().app",
"--host", "0.0.0.0",
"--port", "8000",
"--reload"
])
# Wait a moment for server to start
time.sleep(3)
# Open browser
def open_browser():
time.sleep(2) # Wait a bit more for server to be ready
try:
webbrowser.open('http://localhost:8000')
print("🌐 Browser opened automatically")
except:
print("🌐 Please open http://localhost:8000 in your browser")
browser_thread = threading.Thread(target=open_browser)
browser_thread.daemon = True
browser_thread.start()
print("✅ Web interface is running!")
print("📱 You can access it from any device on your network")
print("🔗 Local: http://localhost:8000")
print("🔗 Network: http://0.0.0.0:8000")
# Wait for server to finish
server_process.wait()
except KeyboardInterrupt:
print("\n⏹️ Web interface stopped by user")
if 'server_process' in locals():
server_process.terminate()
except Exception as e:
print(f"❌ Error starting web interface: {e}")
print("💡 Make sure you have installed the required dependencies:")
print(" pip install fastapi uvicorn")
if __name__ == "__main__":
main()