-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_api.py
More file actions
executable file
·55 lines (47 loc) · 1.48 KB
/
run_api.py
File metadata and controls
executable file
·55 lines (47 loc) · 1.48 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
#!/usr/bin/env python3
"""
FastAPI Server Startup Script
Run this script to start the AI Content Processing API server.
"""
import uvicorn
import os
import sys
from pathlib import Path
# Add the project root to Python path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
def main():
"""Start the FastAPI server."""
# Check for environment variables
env_file = project_root / '.env'
if not env_file.exists():
print("⚠️ Warning: .env file not found")
print(" Create a .env file with your API keys (see env_example.txt)")
print(" The server will start but some processors may not work")
print()
# Get configuration
host = os.getenv('API_HOST', '0.0.0.0')
port = int(os.getenv('API_PORT', '8000'))
reload = os.getenv('API_RELOAD', 'true').lower() == 'true'
log_level = os.getenv('API_LOG_LEVEL', 'info')
print(f"🚀 Starting AI Content Processing API...")
print(f" Host: {host}")
print(f" Port: {port}")
print(f" Reload: {reload}")
print(f" Log Level: {log_level}")
print()
print(f"📖 API Documentation will be available at:")
print(f" Swagger UI: http://{host}:{port}/docs")
print(f" ReDoc: http://{host}:{port}/redoc")
print()
# Start the server
uvicorn.run(
"api_server:app",
host=host,
port=port,
reload=reload,
log_level=log_level,
access_log=True
)
if __name__ == "__main__":
main()