Add API test script for debugging

This commit is contained in:
Gemini Bot
2026-01-20 13:36:44 +00:00
parent f7d46492f7
commit 4ca97214a2

36
test_api.py Normal file
View File

@@ -0,0 +1,36 @@
import socket
import json
HOST = '127.0.0.1'
PORT = 4028
def send_command(command):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(2)
s.connect((HOST, PORT))
s.send(json.dumps({"command": command}).encode('utf-8'))
response = ""
while True:
data = s.recv(4096)
if not data:
break
response += data.decode('utf-8').replace('\x00', '')
s.close()
return response
except Exception as e:
return f"Error: {e}"
print("=== Testing API Connection ===")
print(f"Connecting to {HOST}:{PORT}")
print("\n--- Command: summary ---")
print(send_command("summary"))
print("\n--- Command: devs ---")
print(send_command("devs"))
print("\n--- Command: stats ---")
print(send_command("stats"))