ShopTRAINING/test/test_models_api.py
2025-07-02 11:05:23 +08:00

28 lines
874 B
Python

#!/usr/bin/env python3
"""
测试模型管理API端点
"""
import requests
import json
def test_models_api():
try:
# 测试获取模型列表
response = requests.get('http://localhost:5000/api/models')
print(f"Status Code: {response.status_code}")
print(f"Response Headers: {dict(response.headers)}")
if response.status_code == 200:
data = response.json()
print(f"Response Data: {json.dumps(data, indent=2, ensure_ascii=False)}")
else:
print(f"Error Response: {response.text}")
except requests.exceptions.ConnectionError:
print("连接错误: API服务器可能未启动")
print("请先启动API服务器: uv run ./server/api.py")
except Exception as e:
print(f"请求异常: {e}")
if __name__ == "__main__":
test_models_api()