twisted.web: returning dynamically generated images as image/png
I have the following setup (see below), in which the render method of a RasterServer instance is responsible for generating a png file data in memory that then should be passed on to the client that made the request. However, I can't get my head around how to define the content-type for the render method result? Or whether that's possible at all? If not, how should I define my RasterServer so that it would return image/png content to the client? Cheers, Jussi ======================================== from twisted.web import resource, static, server from twisted.application import service, strports ... root = resource.Resource() ... raster = RasterServer() root.putChild('wms', raster) ... application = service.Application('test') mo_server = strports.service(where, server.Site(root)) mo_server.setServiceParent(application) ---------------- class RasterServer(resource.Resource): def render(self, request): ....
On Sep 2, 2009, at 11:18 AM, Jussi Rasinmäki wrote:
I have the following setup (see below), in which the render method of a RasterServer instance is responsible for generating a png file data in memory that then should be passed on to the client that made the request. However, I can't get my head around how to define the content-type for the render method result? Or whether that's possible at all? If not, how should I define my RasterServer so that it would return image/png content to the client?
Cheers, Jussi
We actually just discussed something like this: http://twistedmatrix.com/pipermail/twisted-web/2009-August/004318.html You're looking for: request.setHeader('Content-Type', 'image/png') -phil
Right, figures. Thought it had to be something trivial, but failed to see the obvious... Thanks a million. Jussi 2009/9/2 Phil Christensen <phil@bubblehouse.org>:
request.setHeader('Content-Type', 'image/png')
2009/9/2 Phil Christensen <phil@bubblehouse.org>:
On Sep 2, 2009, at 11:18 AM, Jussi Rasinmäki wrote:
I have the following setup (see below), in which the render method of a RasterServer instance is responsible for generating a png file data in memory that then should be passed on to the client that made the request. However, I can't get my head around how to define the content-type for the render method result? Or whether that's possible at all? If not, how should I define my RasterServer so that it would return image/png content to the client?
Cheers, Jussi
We actually just discussed something like this:
http://twistedmatrix.com/pipermail/twisted-web/2009-August/004318.html
You're looking for:
request.setHeader('Content-Type', 'image/png')
-phil _______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
participants (2)
-
Jussi Rasinmäki
-
Phil Christensen