[Twisted-web] xmlrpc question
Eric Mangold
teratorn at world-net.net
Tue Nov 30 17:28:33 MST 2004
On Tue, 30 Nov 2004 13:19:00 -0700, <lotek at softhome.net> wrote:
> How can i do this in twisted? from SimpleXMLRPCServer import
> SimpleXMLRPCServer, SimpleXMLRPCRequestHandler class
> ExtendedXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
> def do_GET(self):
> #only allow a request for the crossdomain file
> #this can be changed to support GETs of any file if needed
> if self.path != '/crossdomain.xml':
> self.send_response(403)
> self.log_request(403)
> return #open the crossdomain file and read its contents
> f = file('crossdomain.xml', 'r')
> msg = f.read()
> f.close() #write the data to the socket along with valid HTTP
> headers
> res = 'HTTP/1.0 200 OK\r\nDate: %s\r\n\r\n%s' % \
> (self.date_time_string(),msg)
> self.wfile.write(res)
> self.log_request(200) class EchoClass:
> def echo(self, data):
> return data #create an instance of the class
> s = EchoClass()
> #create the server on localhost
> server = SimpleXMLRPCServer(('', 8000), ExtendedXMLRPCRequestHandler)
> #register the instance as a web service
> server.register_instance(s)
> #start accepting requests
> server.serve_forever()
Where did you get stuck?
-Eric
More information about the Twisted-web
mailing list