import urllib.request import json try: req = urllib.request.Request('http://localhost:8000/api/templates') with urllib.request.urlopen(req, timeout=5) as resp: data = json.loads(resp.read().decode('utf-8')) print(f'总模板数: {len(data)}') models = sorted(set(t['machine_model'] for t in data)) print(f'机型: {models}') types = sorted(set(t['template_type'] for t in data)) print(f'模板类型: {types}') # 打印前5个模板 for t in data[:5]: print(f" - {t['id']}: {t['name']}") except Exception as e: print(f'Error: {e}')