requestHandler=RequestHandler) as server: server.register_introspection_functions()
# Register pow() function; this will use the value of # pow.__name__ as the name, which is just 'pow'. server.register_function(pow)
# Register a function under a different name def adder_function(x, y): return x + y server.register_function(adder_function, 'add')
# Register an instance; all the methods of the instance are # published as XML-RPC methods (in this case, just 'mul'). class MyFuncs: def mul(self, x, y): return x * y
server.register_instance(MyFuncs())
# Run the server's main loop server.serve_forever()</shx> ===== Client ===== <sxh python> import xmlrpc.client s = xmlrpc.client.ServerProxy('http://localhost:8000') print(s.pow(2,3