Skip to content

Instantly share code, notes, and snippets.

@tebeka
Created January 31, 2022 07:42
Show Gist options
  • Save tebeka/8755a8e114984201fac7e4cfefb3cc76 to your computer and use it in GitHub Desktop.
Save tebeka/8755a8e114984201fac7e4cfefb3cc76 to your computer and use it in GitHub Desktop.
from urllib.request import URLError, urlopen
from http import HTTPStatus
class Client:
def __init__(self, host, port):
self.__address = f'https://{host}:{port}'
def health(self):
url = f'{self.__address}/health'
try:
with urlopen(url) as fp:
return fp.status == HTTPStatus.OK
except URLError:
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment