Datasets:
File size: 883 Bytes
2aec8e2 | 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 | from __future__ import annotations
import os
import threading
import webbrowser
from backend import create_app
app = create_app()
def _as_bool(value: str | None, default: bool) -> bool:
if value is None:
return default
return value.strip().lower() not in {"0", "false", "no", "off"}
def _open_browser_later(host: str, port: int) -> None:
if not _as_bool(os.getenv("HVU_OPEN_BROWSER"), True):
return
target_host = "127.0.0.1" if host in {"0.0.0.0", "::"} else host
url = f"http://{target_host}:{port}"
threading.Timer(1.2, lambda: webbrowser.open(url)).start()
if __name__ == "__main__":
host = os.getenv("HVU_HOST", "127.0.0.1")
port = int(os.getenv("HVU_PORT", "5000"))
debug = _as_bool(os.getenv("HVU_DEBUG"), False)
_open_browser_later(host, port)
app.run(host=host, port=port, debug=debug, use_reloader=False)
|