Created
December 3, 2012 01:42
-
-
Save shaunhess/4192086 to your computer and use it in GitHub Desktop.
Python - Quick and Dirty Web Service
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
| # 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