import urllib.request import ssl import sys sys.stdout.reconfigure(encoding='utf-8') token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIzZWUyNTE1MDk0NGU0ZjRjYmJkMGM1MWI5MThmY2EzYiIsImlhdCI6MTc0NjgxMDM3NSwiZXhwIjoyMDYyMTcwMzc1fQ.Le6M7WL63nxtLTxccFacQR5GVUY5C-a_zGtmXT_uaz4" headers = { "Authorization": f"Bearer {token}", "Content-Type": "application/json" } ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE for u in ["http://14.4.4.20:8123/api/states", "https://snarfhome.snarfnet.net/api/states"]: print("Testing:", u) req = urllib.request.Request(u, headers=headers) try: with urllib.request.urlopen(req, timeout=5, context=ctx) as r: print("Status:", r.getcode()) except urllib.error.HTTPError as e: print("HTTP Error:", e.code, e.read().decode()) except Exception as e: print("Exception:", e)