import xmlrpc.server def add_numbers(x, y): return x + y server = xmlrpc.server.SimpleXMLRPCServer(("localhost", 8000)) server.register_function(add_numbers, "add") server.serve_forever()
import xmlrpc.client server = xmlrpc.client.ServerProxy("http://localhost:8000") result = server.add(5, 3) print(result) # prints "8"This example demonstrates how to use an XML-RPC server proxy to make requests to the server created in example 1. The "ServerProxy" class is initialized with the URL of the server. The "add" method is then called on the proxy with two arguments, which returns the sum of the two arguments. In summary, SimpleXMLRPCServer is a module in Python's standard library that enables developers to create basic XML-RPC servers. The module provides a framework for transporting Python objects between processes over network protocols like HTTP.