| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- """
- 探索 192.168.3.218:18183 服务器的 API 结构
- """
- import requests
- import json
- BASE_URL = "http://192.168.3.218:18183"
- def test_endpoint(path, method="GET", params=None):
- """测试一个端点"""
- url = f"{BASE_URL}{path}"
- print(f"\n{'='*60}")
- print(f"测试: {method} {url}")
- if params:
- print(f"参数: {params}")
- print('='*60)
-
- try:
- if method == "GET":
- response = requests.get(url, params=params, timeout=5)
- elif method == "POST":
- response = requests.post(url, json=params, timeout=5)
-
- print(f"状态码: {response.status_code}")
- print(f"响应时间: {response.elapsed.total_seconds():.3f}秒")
-
- try:
- data = response.json()
- print("响应内容:")
- print(json.dumps(data, indent=2, ensure_ascii=False))
- except:
- print("响应内容:")
- print(response.text[:500])
-
- except Exception as e:
- print(f"错误: {str(e)}")
- print("\n" + "🔍 探索 API 结构 ".center(70, "="))
- print(f"服务器: {BASE_URL}")
- # 测试常见的根路径
- print("\n\n📡 测试根路径...")
- test_endpoint("/")
- # 测试 API 路径
- print("\n\n📡 测试可能的 API 路径...")
- test_endpoint("/api")
- # 测试元数据相关路径
- print("\n\n📡 测试元数据相关路径...")
- possible_paths = [
- "/api/meta",
- "/api/metadata",
- "/meta",
- "/metadata",
- "/api/meta/list",
- "/api/meta/node/list",
- ]
- for path in possible_paths:
- test_endpoint(path)
- # 测试 health check
- print("\n\n📡 测试健康检查...")
- test_endpoint("/health")
- test_endpoint("/api/health")
- print("\n\n" + "="*70)
- print("探索完成!")
- print("="*70)
|