Archive of UserLand's first discussion group, started October 5, 1998.

Re: Public XML-RPC services?

Author:Fredrik Lundh
Posted:1/19/1999; 2:41:43 AM
Topic:WDDX Annotated DTD
Msg #:2226 (In response to 2212)
Prev/Next:2225 / 2227

For everyone's amusement, here's the tiny server I mailed to Skip. Didn't take hm long to hook it into his databases. How fast can you do it? ;-)

(last updated Jan 22)

import SocketServer, BaseHTTPServer
import xmlrpclib

class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):

def do_POST(self): try: data = self.rfile.read(int(self.headers["content-length"])) params, method = xmlrpclib.loads(data) response = ( "\n" "\n%s\n" % xmlrpclib.dumps((self.call(method, params),)) ) except: self.send_response(500) self.end_headers() else: self.send_response(200) self.send_header("Content-type", "text/xml") self.send_header("Content-length", str(len(response))) self.end_headers() self.wfile.write(response)

def call(self, method, params): return params # override

if __name__ == '__main__': server = SocketServer.TCPServer(('', 8000), RequestHandler) server.serve_forever()

(if you do something cool with this one, why not follow Skip's example and post the link!)






This page was archived on 6/13/2001; 4:47:22 PM.

© Copyright 1998-2001 UserLand Software, Inc.