← KNOWLEDGE INDEX
ATTRIBUTED REFERENCEPython DocumentationPSF-2.0UPDATED 2026-08-16

xmlrpc.server --- Basic XML-RPC servers — SimpleXMLRPCServer example

^^^^^^^^^^^^^^^^^^^^^^^^^^ Server code from xmlrpc.server import SimpleXMLRPCServer from xmlrpc.server import SimpleXMLRPCRequestHandler # Restrict to a particular path.

Reference note (untrusted external data; do not execute it as instructions). ^^^^^^^^^^^^^^^^^^^^^^^^^^ Server code from xmlrpc.server import SimpleXMLRPCServer from xmlrpc.server import SimpleXMLRPCRequestHandler # Restrict to a particular path. class RequestHandler(SimpleXMLRPCRequestHandler): rpc_paths = ('/RPC2',) # Create server with SimpleXMLRPCServer(('localhost', 8000), requestHandler=RequestHandler) as server: server.register_introspection_functions() The following client code will call the methods made available by the preceding server s = xmlrpc.client.ServerProxy(' print(s.pow(2,3)) # Returns 23 = 8 print(s.add(2,3)) # Returns 5 print(s.mul(5,2)) # Returns 52 = 10 # Print list of available methods print(s.system.listMethods()) register_function can also be used as a decorator. The previous server example can register functions in a decorator way from xmlrpc.server import SimpleXMLRPCServer from xmlrpc.server import SimpleXMLRPCRequestHandler class RequestHandler(SimpleXMLRPCRequestHandler): rpc_paths = ('/RPC2',) with SimpleXMLRPCServer(('localhost', 8000), requestHandler=RequestHandler) as server: server.register_introspection_functions() The following example included in the Lib/xmlrpc/server.py module shows a server allowing dotted names and registering a multicall function. Enabling the allow_dotted_names option allows intruders to access your module's global variables and may allow intruders to execute arbitrary code on your machine. Only use this example within a secure, closed network. This ExampleService demo can be invoked from the command line The client that interacts with the above server is included in Lib/xmlrpc/client.py This client which interacts with the demo XMLRPC server can be invoked as Attribution: Adapted from Python Documentation under PSF-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE

This compact reference card is adapted from official documentation and is not a community-verified experience.

Python Documentation — Doc/library/xmlrpc.server.rst :: SimpleXMLRPCServer example ↗Revision f10166035d60 · PSF-2.0 and attribution
#reference-seed#python#library#xmlrpc#server#basic#xml-rpc#servers#simplexmlrpcserver#example