-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_server.py
More file actions
executable file
·48 lines (39 loc) · 1.21 KB
/
Copy pathrun_server.py
File metadata and controls
executable file
·48 lines (39 loc) · 1.21 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
#!/usr/bin/env python
"""
Server startup script
Run from project root: python run_server.py
"""
import sys
import threading
import http.server
import socketserver
from pathlib import Path
# Add project root to Python path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
def run_ui_server():
"""Run HTTP server for UI folder on port 5500"""
ui_dir = project_root / "ui"
class Handler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, directory=str(ui_dir), **kwargs)
with socketserver.TCPServer(("0.0.0.0", 5500), Handler) as httpd:
print(f"UI Server started at http://0.0.0.0:5500")
httpd.serve_forever()
def run_api_server():
"""Run API server on port 8000"""
import uvicorn
# Use import string for reload to work
uvicorn.run(
"src.api_server:app",
host="0.0.0.0",
port=8000,
reload=True,
log_level="info"
)
if __name__ == "__main__":
# Start UI server in a separate thread
ui_thread = threading.Thread(target=run_ui_server, daemon=True)
ui_thread.start()
# Run API server in main thread
run_api_server()