Merge pull request #391 from Aquafina-water-bottle/readme_localhost

Updated Python example code to use 127.0.0.1 instead of localhost
This commit is contained in:
Alexei Yatskov 2023-06-15 20:13:30 -07:00 committed by GitHub
commit eef3be8599
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -102,7 +102,7 @@ def request(action, **params):
def invoke(action, **params): def invoke(action, **params):
requestJson = json.dumps(request(action, **params)).encode('utf-8') requestJson = json.dumps(request(action, **params)).encode('utf-8')
response = json.load(urllib.request.urlopen(urllib.request.Request('http://localhost:8765', requestJson))) response = json.load(urllib.request.urlopen(urllib.request.Request('http://127.0.0.1:8765', requestJson)))
if len(response) != 2: if len(response) != 2:
raise Exception('response has an unexpected number of fields') raise Exception('response has an unexpected number of fields')
if 'error' not in response: if 'error' not in response: