extends Node

# 简单的API测试脚本
const API_BASE_URL = "https://whaletownend.xinghangee.icu"

func _ready():
	print("API测试脚本已加载")
	print("服务器地址: ", API_BASE_URL)
	
	# 测试服务器连接
	test_server_status()

func test_server_status():
	var http_request = HTTPRequest.new()
	add_child(http_request)
	http_request.request_completed.connect(_on_status_request_completed)
	
	print("正在测试服务器连接...")
	var error = http_request.request(API_BASE_URL)
	if error != OK:
		print("请求失败: ", error)

func _on_status_request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray):
	var response_text = body.get_string_from_utf8()
	print("服务器状态响应: ", response_code)
	print("响应内容: ", response_text)
	
	if response_code == 200:
		print("✅ 服务器连接正常")
	else:
		print("❌ 服务器连接失败")
