-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_server.py
More file actions
59 lines (52 loc) · 1.73 KB
/
run_server.py
File metadata and controls
59 lines (52 loc) · 1.73 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
#!/usr/bin/env python3
"""
Script to run the FastAPI server for endpoint testing
"""
import subprocess
import sys
import os
from pathlib import Path
def install_requirements():
"""Install required packages"""
print("Installing requirements...")
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
print("✅ Requirements installed successfully!")
except subprocess.CalledProcessError as e:
print(f"❌ Error installing requirements: {e}")
return False
return True
def run_server():
"""Run the FastAPI server"""
print("🚀 Starting Endpoint Performance Tester API Server...")
print("📍 Server will be available at: http://localhost:3000")
print("📚 API Documentation: http://localhost:3000/docs")
print("🛑 Press Ctrl+C to stop the server")
print("-" * 60)
try:
# Change to the script directory
script_dir = Path(__file__).parent
os.chdir(script_dir)
# Run the server
subprocess.run([
sys.executable, "-m", "uvicorn",
"api_server:app",
"--host", "0.0.0.0",
"--port", "3000",
"--reload"
])
except KeyboardInterrupt:
print("\n🛑 Server stopped by user")
except Exception as e:
print(f"❌ Error running server: {e}")
if __name__ == "__main__":
print("=" * 60)
print("🔧 Endpoint Performance Tester API Server")
print("=" * 60)
# Install requirements first
if install_requirements():
run_server()
else:
print("❌ Failed to install requirements. Please install manually:")
print("pip install -r requirements.txt")
sys.exit(1)