-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart.py
More file actions
70 lines (59 loc) · 1.85 KB
/
start.py
File metadata and controls
70 lines (59 loc) · 1.85 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
#!/usr/bin/env python3
"""
Simple script to start both backend and frontend
"""
import subprocess
import sys
import os
import time
def start_backend():
"""Start the backend server"""
backend_dir = os.path.join(os.path.dirname(__file__), 'backend')
return subprocess.Popen(
[sys.executable, 'start_backend.py'],
cwd=backend_dir,
shell=True
)
def start_frontend():
"""Start the frontend server"""
frontend_dir = os.path.join(os.path.dirname(__file__), 'frontend')
# Check if node_modules exists
if not os.path.exists(os.path.join(frontend_dir, 'node_modules')):
print("Frontend dependencies not installed.")
print("Please run: cd frontend && npm install")
print("Then run this script again.")
sys.exit(1)
return subprocess.Popen(
'npm run dev',
cwd=frontend_dir,
shell=True
)
def main():
print("Starting HomeNetAI...")
print("=" * 50)
# Start backend
print("Starting backend...")
backend_process = start_backend()
time.sleep(2) # Give backend time to start
# Start frontend
print("Starting frontend...")
frontend_process = start_frontend()
time.sleep(2) # Give frontend time to start
print("\nBoth servers started!")
print("Backend: http://localhost:8000")
print("Frontend: http://localhost:8080")
print("API Docs: http://localhost:8000/docs")
print("\nPress Ctrl+C to stop both servers\n")
try:
# Wait for both processes
backend_process.wait()
frontend_process.wait()
except KeyboardInterrupt:
print("\n\nStopping servers...")
backend_process.terminate()
frontend_process.terminate()
backend_process.wait()
frontend_process.wait()
print("Servers stopped")
if __name__ == "__main__":
main()