INNER CODE UNIT · Python
_auto_connect
Chanchaldhiman/CANviz · backend/canviz/cli.py:203
def _auto_connect(do_connect: bool = True) -> None:
import urllib.request
base = f"http://{host}:{port}"
# Wait for server to be ready (up to 15s)
for _ in range(60):
try:
urllib.request.urlopen(f"{base}/status", timeout=1)
break
except Exception:
time.sleep(0.25)
if not do_connect:
# No explicit args given - just open browser, skip /connect
if not headless:
webbrowser.open(url)
return
# POST /connect
body = json.dumps({