| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- 检查系统状态和可用的API端点
- """
- import requests
- import json
- def check_system_status():
- """检查系统状态"""
- base_urls = [
- "http://localhost:8080",
- "http://localhost/dev-api",
- "http://localhost"
- ]
-
- print("🔍 检查系统状态...")
-
- for base_url in base_urls:
- print(f"\n🌐 测试地址: {base_url}")
-
- # 测试基本连接
- try:
- response = requests.get(f"{base_url}/", timeout=5)
- print(f" ✅ 基础连接: {response.status_code}")
- except Exception as e:
- print(f" ❌ 基础连接失败: {str(e)}")
- continue
-
- # 测试登录端点
- try:
- login_endpoints = ["/auth/login", "/login"]
- for endpoint in login_endpoints:
- try:
- response = requests.post(f"{base_url}{endpoint}", json={}, timeout=5)
- print(f" 🔑 登录端点 {endpoint}: {response.status_code}")
- if response.status_code in [200, 400, 401, 403]:
- print(f" 响应: {response.text[:200]}...")
- except Exception as e:
- print(f" ❌ 登录端点 {endpoint} 失败: {str(e)}")
- except Exception as e:
- print(f" ❌ 登录测试失败: {str(e)}")
-
- # 测试API端点
- try:
- api_endpoints = [
- "/classMsg/classMsg/list",
- "/studentMsg/studentMsg/list",
- "/api/classMsg/classMsg/list"
- ]
- for endpoint in api_endpoints:
- try:
- response = requests.get(f"{base_url}{endpoint}", timeout=5)
- print(f" 📊 API端点 {endpoint}: {response.status_code}")
- if response.text:
- data = response.json()
- if data.get('code'):
- print(f" 响应码: {data.get('code')}, 消息: {data.get('msg', '')}")
- except Exception as e:
- print(f" ❌ API端点 {endpoint} 失败: {str(e)}")
- except Exception as e:
- print(f" ❌ API测试失败: {str(e)}")
- if __name__ == "__main__":
- check_system_status()
|