-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_api_server.py
More file actions
55 lines (46 loc) Β· 1.69 KB
/
start_api_server.py
File metadata and controls
55 lines (46 loc) Β· 1.69 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 python
"""
Start the FastAPI visualization server
This script starts the FastAPI server for data visualization.
The server provides REST API endpoints and a web-based visualization dashboard.
Usage:
python start_api_server.py
The server will be available at:
- API endpoints: http://localhost:8000/api/
- Visualization dashboard: http://localhost:8000/viz
- API docs: http://localhost:8000/docs
"""
import uvicorn
from multi_modal_rag.logging_config import setup_logging, get_logger
def main():
"""Start the FastAPI server"""
# Initialize logging
logger, log_file = setup_logging()
logger.info("="*80)
logger.info("Starting FastAPI Visualization Server")
logger.info(f"Log file location: {log_file}")
logger.info("="*80)
print("π Starting FastAPI Visualization Server...")
print("π Dashboard will be available at: http://localhost:8000/viz")
print("π‘ API endpoints at: http://localhost:8000/api/")
print("π API docs at: http://localhost:8000/docs")
print(f"π Logs are being written to: {log_file}")
print("\nPress CTRL+C to stop the server\n")
logger.info("Starting Uvicorn server on 0.0.0.0:8000")
try:
uvicorn.run(
"multi_modal_rag.api.api_server:app",
host="0.0.0.0",
port=8000,
reload=True, # Auto-reload on code changes
log_level="info"
)
except KeyboardInterrupt:
logger.info("Server stopped by user")
print("\nβ
Server stopped")
except Exception as e:
logger.error(f"Server error: {e}", exc_info=True)
print(f"\nβ Server error: {e}")
raise
if __name__ == "__main__":
main()