diff --git a/test_api.py b/test_api.py new file mode 100644 index 0000000..6053c42 --- /dev/null +++ b/test_api.py @@ -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")) +