-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.py
More file actions
28 lines (22 loc) · 957 Bytes
/
Copy pathrun.py
File metadata and controls
28 lines (22 loc) · 957 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
"""Entry point: python run.py (serves API + UI at http://127.0.0.1:8000)."""
import os
from pathlib import Path
import uvicorn
def _load_dotenv() -> None:
"""Load KEY=VALUE lines from a local, gitignored ``.env`` into the environment.
Keeps secrets (e.g. ``OPENROUTER_API_KEY`` for the optional LLM narrator) out
of the source and out of the repo. Existing environment variables win.
"""
env = Path(__file__).with_name(".env")
if not env.exists():
return
for line in env.read_text(encoding="utf-8").splitlines():
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
key, _, val = line.partition("=")
os.environ.setdefault(key.strip(), val.strip().strip('"').strip("'"))
if __name__ == "__main__":
_load_dotenv()
port = int(os.environ.get("PORT", "8000"))
uvicorn.run("app.main:app", host="127.0.0.1", port=port, reload=False)