Mega Code Archive

 
Categories / Python Tutorial / Network
 

Creating an XML-RPC Server

import SimpleXMLRPCServer servAddr = ("localhost", 8080) def areaSquare(length):     return length*length def areaRectangle(length, width):     return length*width def areaCircle(radius):     return 3.14*(radius*radius) serv = SimpleXMLRPCServer.SimpleXMLRPCServer(servAddr) serv.register_function(areaSquare) serv.register_function(areaRectangle) serv.register_function(areaCircle) serv.register_introspection_functions() serv.serve_forever()