-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
30 lines (24 loc) · 760 Bytes
/
run.py
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
import subprocess
import sys
import webbrowser
from time import sleep
def main():
# Start backend server
backend = subprocess.Popen([sys.executable, "-m", "uvicorn", "main:app", "--host", "127.0.0.1", "--port", "3000"])
# Start frontend server
frontend = subprocess.Popen([sys.executable, "-m", "http.server", "8000"])
# Wait a moment for servers to start
sleep(2)
# Open browser
webbrowser.open('http://localhost:8000')
try:
# Keep the script running
backend.wait()
frontend.wait()
except KeyboardInterrupt:
# Handle Ctrl+C gracefully
backend.terminate()
frontend.terminate()
print("\nServers stopped")
if __name__ == "__main__":
main()