fix: module-level app loads config.yaml (uvicorn app.main:app); bind 0.0.0.0 for LAN/device reachability
This commit is contained in:
@@ -31,6 +31,7 @@ cd hermes-xiaozhi-bridge
|
|||||||
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
|
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
|
||||||
.venv/bin/python -m app.main
|
.venv/bin/python -m app.main
|
||||||
# (loads config.yaml from the repo root; override with BRIDGE_CONFIG=/path)
|
# (loads config.yaml from the repo root; override with BRIDGE_CONFIG=/path)
|
||||||
|
# equivalent: .venv/bin/uvicorn app.main:app --host 0.0.0.0 --port 8766
|
||||||
.venv/bin/python -m pytest -q
|
.venv/bin/python -m pytest -q
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
18
app/main.py
18
app/main.py
@@ -38,13 +38,6 @@ def make_app(cfg: Config | None = None) -> FastAPI:
|
|||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
|
||||||
import uvicorn
|
|
||||||
|
|
||||||
cfg = _load_config()
|
|
||||||
uvicorn.run(make_app(cfg), host=cfg.host, port=cfg.port)
|
|
||||||
|
|
||||||
|
|
||||||
def _load_config() -> Config:
|
def _load_config() -> Config:
|
||||||
"""Load config.yaml from the repo root; fall back to all-mock defaults."""
|
"""Load config.yaml from the repo root; fall back to all-mock defaults."""
|
||||||
import os
|
import os
|
||||||
@@ -58,5 +51,16 @@ def _load_config() -> Config:
|
|||||||
return Config()
|
return Config()
|
||||||
|
|
||||||
|
|
||||||
|
# Module-level app so `uvicorn app.main:app` loads config.yaml (REQ: real
|
||||||
|
# token in production). `main()` is the equivalent entrypoint.
|
||||||
|
app = make_app(_load_config())
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
import uvicorn
|
||||||
|
|
||||||
|
uvicorn.run(app, host=app.state.cfg.host, port=app.state.cfg.port)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
# Protocol values marked FIRMWARE are PoC assumptions — verify against the
|
# Protocol values marked FIRMWARE are PoC assumptions — verify against the
|
||||||
# real Xiaozhi firmware before locking (CON-004).
|
# real Xiaozhi firmware before locking (CON-004).
|
||||||
|
|
||||||
host: 127.0.0.1
|
host: 0.0.0.0 # LAN reachable (device on 192.168.1.x)
|
||||||
port: 8766
|
port: 8766
|
||||||
ws_path: /ws/xiaozhi
|
ws_path: /ws/xiaozhi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user