Skip to content

Instantly share code, notes, and snippets.

@xiantail
Created December 28, 2015 09:29
Show Gist options
  • Save xiantail/eef17c1e9a71d50c3d56 to your computer and use it in GitHub Desktop.
Save xiantail/eef17c1e9a71d50c3d56 to your computer and use it in GitHub Desktop.
Introducing Python / Chap.11 Exercise 11.3
from xmlrpc.server import SimpleXMLRPCServer
from datetime import datetime
def current_time():
now = str(datetime.now())
print('Server sent %s', now)
return now
server = SimpleXMLRPCServer(("localhost", 6789))
server.register_function(current_time, "current_time")
server.serve_forever()
import xmlrpc.client
from datetime import datetime
from time import sleep
proxy = xmlrpc.client.ServerProxy("http://localhost:6789/")
while True:
sleep(3)
result = proxy.current_time()
print("Current time is %s" % result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment