import requests import json # 配置 BASE_URL = "http://localhost:8448" API_URL = f"{BASE_URL}/watershed/model/list/test" def test_get_models(): print("开始测试获取模型列表接口...") try: params = { 'page': 1, 'size': 10 } print(f"请求 URL: {API_URL}?{'&'.join([f'{k}={v}' for k, v in params.items()])}") response = requests.get(API_URL, params=params) print(f"响应状态码: {response.status_code}") print(f"响应内容:\n{response.text}") if response.status_code == 200: data = response.json() print("\n✅ 请求成功") print(f"响应数据结构: {json.dumps(data, indent=2, ensure_ascii=False)}") if 'rows' in data: print(f"\n模型数量: {len(data['rows'])}") if data['rows']: print("\n第一个模型的字段:") first_model = data['rows'][0] for key in first_model.keys(): print(f" {key}: {first_model[key]}") else: print(f"\n❌ 请求失败: {response.text}") except Exception as e: print(f"\n❌ 请求发生异常: {e}") if __name__ == "__main__": test_get_models()