Skip to content

Instantly share code, notes, and snippets.

@studiawan
Created December 30, 2013 05:01
Show Gist options
  • Save studiawan/8178017 to your computer and use it in GitHub Desktop.
Save studiawan/8178017 to your computer and use it in GitHub Desktop.
XML RPC server that has many functions
# http://docs.python.org/2/library/xmlrpclib.html
from SimpleXMLRPCServer import SimpleXMLRPCServer
def add(x,y):
return x+y
def subtract(x, y):
return x-y
def multiply(x, y):
return x*y
def divide(x, y):
return x/y
# A simple server with simple arithmetic functions
server = SimpleXMLRPCServer(("localhost", 8000))
print "Listening on port 8000..."
server.register_introspection_functions()
server.register_multicall_functions()
server.register_function(add, 'add')
server.register_function(subtract, 'subtract')
server.register_function(multiply, 'multiply')
server.register_function(divide, 'divide')
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment