ocngx / test-api-endpoints.sh
tanbushi's picture
update
4c82f7f
Raw
History Blame
1.3 kB
#!/bin/bash
# 测试API端点访问
echo "🔍 测试OpenCode API端点访问..."
base_url="https://airsltd-ocngx.hf.space"
# 测试各个API端点
test_endpoints=(
"/global/health"
"/global/event"
"/session"
"/project"
"/provider"
"/file"
"/find"
"/config"
"/doc"
)
echo "📡 测试API端点..."
for endpoint in "${test_endpoints[@]}"; do
echo -n " $endpoint: "
response=$(curl -s -w "%{http_code}" "${base_url}${endpoint}")
http_code="${response: -3}"
if [ "$http_code" = "200" ]; then
echo "✅ 200 OK"
elif [ "$http_code" = "404" ]; then
echo "❌ 404 Not Found"
elif [ "$http_code" = "401" ]; then
echo "❌ 401 Unauthorized"
elif [ "$http_code" = "405" ]; then
echo "✅ 405 Method Not Allowed (正常,端点存在但不支持GET)"
else
echo "❓ $http_code"
fi
done
echo ""
echo "🌐 测试主页面和关键功能..."
main_response=$(curl -s -w "%{http_code}" "${base_url}/opencode/")
main_http_code="${main_response: -3}"
if [ "$main_http_code" = "200" ]; then
echo "✅ 主页面 200 OK"
else
echo "❌ 主页面 $main_http_code"
fi
echo ""
echo "🎯 测试完成!"
echo "📱 如果所有API端点都是200,则Web界面应该完全正常工作"