37 lines
845 B
Python
37 lines
845 B
Python
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"))
|
|
|