-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_aethercode.py
More file actions
77 lines (61 loc) · 2.32 KB
/
Copy pathstart_aethercode.py
File metadata and controls
77 lines (61 loc) · 2.32 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
72
73
74
75
76
77
"""
AetherCode - Startup Script
This script starts both the frontend and backend servers
"""
import os
import subprocess
import sys
import threading
import time
import webbrowser
def start_backend():
"""Start the Flask backend server"""
print("Starting backend server...")
backend_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "backend")
# Check if we're on Windows or Unix
if sys.platform.startswith('win'):
process = subprocess.Popen(["python", "run_backend.py"], cwd=backend_dir)
else:
process = subprocess.Popen(["python3", "run_backend.py"], cwd=backend_dir)
return process
def start_frontend():
"""Start the frontend server using Python's http.server"""
print("Starting frontend server...")
frontend_dir = os.path.dirname(os.path.abspath(__file__))
# Check if we're on Windows or Unix
if sys.platform.startswith('win'):
process = subprocess.Popen(["python", "-m", "http.server", "8000"], cwd=frontend_dir)
else:
process = subprocess.Popen(["python3", "-m", "http.server", "8000"], cwd=frontend_dir)
return process
def main():
"""Main function to start both servers"""
print("Starting AetherCode application...")
# Start backend server in a separate process
backend_process = start_backend()
# Wait for backend to initialize
print("Waiting for backend server to initialize...")
time.sleep(2)
# Start frontend server in a separate process
frontend_process = start_frontend()
# Wait for frontend to initialize
print("Waiting for frontend server to initialize...")
time.sleep(1)
# Open the application in the default web browser
print("Opening AetherCode in your web browser...")
webbrowser.open("http://localhost:8000")
print("\nAetherCode is now running!")
print("Frontend: http://localhost:8000")
print("Backend API: http://localhost:5000/api")
print("\nPress Ctrl+C to stop the servers")
try:
# Keep the script running until interrupted
while True:
time.sleep(1)
except KeyboardInterrupt:
print("\nShutting down AetherCode...")
backend_process.terminate()
frontend_process.terminate()
print("Servers stopped. Goodbye!")
if __name__ == "__main__":
main()