-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathstart_versioned_api.py
More file actions
50 lines (45 loc) · 1.6 KB
/
Copy pathstart_versioned_api.py
File metadata and controls
50 lines (45 loc) · 1.6 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
#!/usr/bin/env python3
"""
Startup script for the versioned TTL Archival Service API
"""
import uvicorn
import sys
import os
# Add the backend directory to the Python path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'backend'))
def main():
"""Start the versioned API server"""
print("🚀 Starting TTL Archival Service with API Versioning...")
print("📋 Versioning Features:")
print(" ✅ URL-based versioning (/api/v1/, /api/v2/)")
print(" ✅ Header-based versioning (X-API-Version, Accept)")
print(" ✅ Deprecation warnings and headers")
print(" ✅ Version negotiation middleware")
print(" ✅ Enhanced v2 features (batch ops, webhooks, notifications)")
print()
print("🌐 Available endpoints:")
print(" 📖 Version Info: http://localhost:8000/version")
print(" 💚 Health Check: http://localhost:8000/health")
print(" 📚 API Docs: http://localhost:8000/docs")
print(" 🧪 Test Script: python test_versioning.py")
print()
print("🔧 Version Examples:")
print(" v1 (deprecated): http://localhost:8000/api/v1/archives")
print(" v2 (current): http://localhost:8000/api/v2/archives")
print()
try:
# Start the server
uvicorn.run(
"backend.main:app",
host="0.0.0.0",
port=8000,
reload=True,
log_level="info"
)
except KeyboardInterrupt:
print("\n👋 Server stopped by user")
except Exception as e:
print(f"❌ Failed to start server: {e}")
sys.exit(1)
if __name__ == "__main__":
main()