forked from lfnovo/open-notebook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_api.py
More file actions
42 lines (33 loc) · 1017 Bytes
/
run_api.py
File metadata and controls
42 lines (33 loc) · 1017 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
41
42
#!/usr/bin/env python3
"""
Startup script for Open Notebook API server.
"""
import os
import sys
from pathlib import Path
from pathlib import Path
from dotenv import load_dotenv
import uvicorn
# Load environment variables from .env.local if it exists, otherwise fall back to .env
env_local = Path(".env.local")
if env_local.exists():
load_dotenv(dotenv_path=env_local)
else:
load_dotenv()
# Add the current directory to Python path so imports work
current_dir = Path(__file__).parent
sys.path.insert(0, str(current_dir))
if __name__ == "__main__":
# Default configuration
host = os.getenv("API_HOST", "127.0.0.1")
port = int(os.getenv("API_PORT", "5055"))
reload = os.getenv("API_RELOAD", "true").lower() == "true"
print(f"Starting Open Notebook API server on {host}:{port}")
print(f"Reload mode: {reload}")
uvicorn.run(
"api.main:app",
host=host,
port=port,
reload=reload,
reload_dirs=[str(current_dir)] if reload else None,
)