File size: 590 Bytes
7363a4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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}")