mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #19082: Working xmlrpc.server and xmlrpc.client examples. Both in modules and in documentation.
This commit is contained in:
parent
0abbe8c090
commit
939e2db48d
4 changed files with 86 additions and 5 deletions
|
@ -967,10 +967,24 @@ class DocCGIXMLRPCRequestHandler( CGIXMLRPCRequestHandler,
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import datetime
|
||||
|
||||
class ExampleService:
|
||||
def getData(self):
|
||||
return '42'
|
||||
|
||||
class currentTime:
|
||||
@staticmethod
|
||||
def getCurrentTime():
|
||||
return datetime.datetime.now()
|
||||
|
||||
server = SimpleXMLRPCServer(("localhost", 8000))
|
||||
server.register_function(pow)
|
||||
server.register_function(lambda x,y: x+y, 'add')
|
||||
server.register_instance(ExampleService(), allow_dotted_names=True)
|
||||
server.register_multicall_functions()
|
||||
print('Serving XML-RPC on localhost port 8000')
|
||||
print('It is advisable to run this example server within a secure, closed network.')
|
||||
try:
|
||||
server.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue