Last active
June 24, 2020 15:55
-
-
Save Kenan7/61abf468104339294f2e23af7e82b522 to your computer and use it in GitHub Desktop.
XML-RPC Python server-client example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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