-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.py
More file actions
80 lines (65 loc) · 2.25 KB
/
start.py
File metadata and controls
80 lines (65 loc) · 2.25 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
78
79
80
"""
Quick start script for Meteorite Impact Simulator
"""
import os
import sys
import subprocess
import webbrowser
import time
import threading
def check_dependencies():
"""Verify that dependencies are installed"""
print("🔍 Verifying dependencies...")
try:
import flask # type: ignore
print("✅ Flask installed")
except ImportError:
print("❌ Flask not installed. Running: pip install flask")
subprocess.run([sys.executable, "-m", "pip", "install", "flask"])
try:
import requests # type: ignore
print("✅ Requests installed")
except ImportError:
print("❌ Requests not installed. Running: pip install requests")
subprocess.run([sys.executable, "-m", "pip", "install", "requests"])
def start_server():
"""Initialize Flask server"""
print("🚀 Starting server...")
# Change to project directory
script_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(script_dir)
# Start server
try:
subprocess.run([sys.executable, "server.py"])
except KeyboardInterrupt:
print("\n👋 Server stopped by user")
except Exception as e:
print(f"❌ Error starting server: {e}")
def open_browser():
"""Open browser after brief delay"""
time.sleep(3) # Wait for server to start
try:
webbrowser.open('http://localhost:5000')
print("🌐 Browser opened at http://localhost:5000")
except Exception as e:
print(f"⚠️ Could not open browser automatically: {e}")
print("🌐 Open manually: http://localhost:5000")
def main():
"""Main function"""
print("🌍 Meteorite Impact Simulator")
print("=" * 50)
# Verify dependencies
check_dependencies()
print("\n📋 Instructions:")
print("1. Server will start at http://localhost:5000")
print("2. Browser will open automatically")
print("3. To stop server, press Ctrl+C")
print("4. 2D simulation will launch when you start a simulation")
input("\n⏎ Press Enter to continue...")
# Start browser in separate thread
browser_thread = threading.Thread(target=open_browser)
browser_thread.daemon = True
browser_thread.start()
# Start server
start_server()
main()