68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""
|
||
|
|
Professional API Documentation Server Launcher
|
||
|
|
Starts both the main API and the professional Swagger UI documentation.
|
||
|
|
"""
|
||
|
|
|
||
|
|
import subprocess
|
||
|
|
import time
|
||
|
|
import sys
|
||
|
|
import os
|
||
|
|
|
||
|
|
def start_main_api():
|
||
|
|
"""Start the main API server on port 5002."""
|
||
|
|
print("🚀 Starting Main API Server (Port 5002)...")
|
||
|
|
return subprocess.Popen([sys.executable, 'main.py'])
|
||
|
|
|
||
|
|
def start_swagger_docs():
|
||
|
|
"""Start the professional Swagger UI documentation on port 5003."""
|
||
|
|
print("📚 Starting Professional API Documentation (Port 5003)...")
|
||
|
|
time.sleep(2) # Wait for main API to start
|
||
|
|
return subprocess.Popen([sys.executable, 'swagger_app.py'])
|
||
|
|
|
||
|
|
def main():
|
||
|
|
"""Start both servers."""
|
||
|
|
print("=" * 60)
|
||
|
|
print("🔍 MEMORY MODULE DETECTION API - PROFESSIONAL SETUP")
|
||
|
|
print("=" * 60)
|
||
|
|
|
||
|
|
# Check if virtual environment is activated
|
||
|
|
if not hasattr(sys, 'real_prefix') and not (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix):
|
||
|
|
print("⚠️ Warning: Virtual environment not detected!")
|
||
|
|
print("💡 Recommendation: Run 'source venv/bin/activate' first")
|
||
|
|
print("")
|
||
|
|
|
||
|
|
try:
|
||
|
|
# Start main API
|
||
|
|
main_process = start_main_api()
|
||
|
|
|
||
|
|
# Start documentation
|
||
|
|
docs_process = start_swagger_docs()
|
||
|
|
|
||
|
|
print("")
|
||
|
|
print("✅ Both servers started successfully!")
|
||
|
|
print("")
|
||
|
|
print("🌐 MAIN API (Web Interface):")
|
||
|
|
print(" http://localhost:5002")
|
||
|
|
print("")
|
||
|
|
print("📚 PROFESSIONAL API DOCS (Swagger UI):")
|
||
|
|
print(" http://localhost:5003")
|
||
|
|
print("")
|
||
|
|
print("🔧 BUILT-IN API DOCS:")
|
||
|
|
print(" http://localhost:5002/docs/")
|
||
|
|
print("")
|
||
|
|
print("Press Ctrl+C to stop both servers...")
|
||
|
|
|
||
|
|
# Wait for processes
|
||
|
|
while True:
|
||
|
|
time.sleep(1)
|
||
|
|
|
||
|
|
except KeyboardInterrupt:
|
||
|
|
print("\n🛑 Stopping servers...")
|
||
|
|
main_process.terminate()
|
||
|
|
docs_process.terminate()
|
||
|
|
print("✅ Servers stopped successfully!")
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
main()
|