import socket import json client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect(('localhost', 8080)) def makeRequest(method, path, data): request = data request['method'] = method request['path'] = path return json.dumps(request).encode('utf-8') data = {"clientName": "client2", "greenTimer": 3, "yellowTimer": 2, "redTimer": 3} client_socket.sendall(makeRequest('POST', '/config', data)) response = client_socket.recv(1024) client_socket.close() print(response.decode('utf-8'))