26 lines
888 B
Python
26 lines
888 B
Python
|
|
import urllib.request, json
|
||
|
|
def get(path):
|
||
|
|
r = urllib.request.urlopen(f'http://127.0.0.1:8765{path}', timeout=5)
|
||
|
|
return json.loads(r.read())
|
||
|
|
|
||
|
|
print('=== Health ===')
|
||
|
|
print(get('/api/health'))
|
||
|
|
|
||
|
|
print('\n=== Favorites (raw) ===')
|
||
|
|
r = get('/api/dashboard/favorites')
|
||
|
|
print(f'Type: {type(r).__name__}, len: {len(r) if isinstance(r, list) else "N/A"}')
|
||
|
|
if isinstance(r, list) and r:
|
||
|
|
print(f'First item type: {type(r[0]).__name__}')
|
||
|
|
print(f'First item: {r[0]}')
|
||
|
|
elif isinstance(r, dict):
|
||
|
|
print(f'Keys: {list(r.keys())}')
|
||
|
|
if 'detail' in r: print(f'Error: {r}')
|
||
|
|
|
||
|
|
print('\n=== Overview ===')
|
||
|
|
r = get('/api/dashboard/overview')
|
||
|
|
print(json.dumps({k:v for k,v in r.items() if not isinstance(v, list)}, indent=2))
|
||
|
|
|
||
|
|
print('\n=== Dashboard HTML ===')
|
||
|
|
r2 = urllib.request.urlopen('http://127.0.0.1:8765/dashboard', timeout=5)
|
||
|
|
print(f'Status: {r2.status}, {len(r2.read())} bytes')
|