Skip to content

Instantly share code, notes, and snippets.

@Kenan7
Last active June 24, 2020 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kenan7/61abf468104339294f2e23af7e82b522 to your computer and use it in GitHub Desktop.
Save Kenan7/61abf468104339294f2e23af7e82b522 to your computer and use it in GitHub Desktop.
XML-RPC Python server-client example
import xmlrpc.client
with xmlrpc.client.ServerProxy("http://localhost:5080/") as proxy:
print("sum of 1 and 1 is: %s" % str(proxy.add(1, 1)))
print("subtraction of 2 from 5 is: %s" % str(proxy.sub(5, 2)))
from xmlrpc.server import SimpleXMLRPCServer
def add(x, y):
return x + y
def sub(x, y):
return x - y
srv = SimpleXMLRPCServer(("localhost", 5080))
srv.register_function(add, 'add')
srv.register_function(sub, 'sub')
srv.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment