Skip to content

Instantly share code, notes, and snippets.

@shaunhess
Created December 3, 2012 01:42
Show Gist options
  • Select an option

  • Save shaunhess/4192086 to your computer and use it in GitHub Desktop.

Select an option

Save shaunhess/4192086 to your computer and use it in GitHub Desktop.
Python - Quick and Dirty Web Service
# Server Side
from SimpleXMLRPCServer import SimpleXMLRPCServer
def file_reader(file_name):
with open(file_name, 'r') as f:
return f.read()
server = SimpleXMLRPCServer(('localhost', 8000))
server.register_introspection_functions()
server.register_function(file_reader)
server.serve_forever()
# Client Side
import xmlrpclib
proxy = xmlrpclib.ServerProxy('http://localhost:8000/')
proxy.file_reader('/tmp/secret.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment