| import urllib.request | |
| import json | |
| try: | |
| url = "http://127.0.0.1:7860/api/results?dataset=Authorship" | |
| with urllib.request.urlopen(url) as response: | |
| data = json.loads(response.read().decode()) | |
| print(f"Status Code: {response.getcode()}") | |
| print(f"Type: {type(data)}") | |
| if isinstance(data, list): | |
| print(f"Length: {len(data)}") | |
| if len(data) > 0: | |
| print(f"First item keys: {data[0].keys()}") | |
| else: | |
| print("Data is NOT a list!") | |
| print(data) | |
| except Exception as e: | |
| print(f"Error: {e}") | |