forked from gowriganeshns/Projectwork1
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun_server.py
More file actions
40 lines (32 loc) · 1022 Bytes
/
run_server.py
File metadata and controls
40 lines (32 loc) · 1022 Bytes
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
#!/usr/bin/env python3
"""
Simple server startup script
"""
import os
import sys
import subprocess
from pathlib import Path
# Set project root
BASE_DIR = Path(__file__).resolve().parent
SRC_DIR = BASE_DIR / "src"
# Make sure src is in the path
sys.path.insert(0, str(SRC_DIR))
# Get port from environment or default to 8000
PORT = int(os.environ.get("PORT", 8000))
if __name__ == "__main__":
print("🚀 Starting Nginx WAF AI Server...")
print(f"📡 API Docs: http://localhost:{PORT}/docs")
print(f"🔍 Health Check: http://localhost:{PORT}/health")
# Run uvicorn as a module to handle relative imports properly
cmd = [
sys.executable, "-m", "uvicorn",
"src.main:app",
"--host", "0.0.0.0",
"--port", str(PORT),
"--log-level", "info"
]
# Optional: enable auto-reload in development
if os.environ.get("DEV_MODE", "0") == "1":
cmd.append("--reload")
# Run the server
subprocess.run(cmd)