diff options
author | Robby Zambito <contact@robbyzambito.me> | 2025-08-06 16:31:31 -0400 |
---|---|---|
committer | Robby Zambito <contact@robbyzambito.me> | 2025-08-06 18:13:24 -0400 |
commit | 0b3451b2bbec0d55ff0cff9def77f09b940bff4d (patch) | |
tree | 68aa777397bbf77988b72652c486284121b2aff1 | |
parent | 8e66913ef0fbe55acc79ba0e439bec0d527adbd1 (diff) |
Add scoring utility function
-rw-r--r-- | current_king.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/current_king.py b/current_king.py new file mode 100644 index 0000000..4334140 --- /dev/null +++ b/current_king.py @@ -0,0 +1,12 @@ +import urllib.request +import urllib.error + +def get_king_data(): + """Request data from localhost king endpoint and return response body as string.""" + try: + with urllib.request.urlopen("http://localhost:8080/v1/king") as response: + return response.read().decode('utf-8') + except urllib.error.URLError as e: + raise Exception(f"Failed to fetch king data: {e}") + +print(get_king_data()) |