I'm experimenting with non-html servlets. Based on code in XMLRPCServlet, I
made this quick hack:

---------------------------
from WebKit.Page import Page

class gifpage(Page):
 def writeHTML(self):
  # get a bunch of data to send as image...
  file = open('d:\\apps\\gallery\\publish\\gfx\\logo.gif','rb')
  pic = file.read()
  file.close()

  # change the headers sent out by the httpd to reflect a new mimetype
  trans = self._transaction
  trans.response().setStatus(200, 'OK')
  trans.response().setHeader("Content-type", "image/gif")
  trans.response().setHeader("Content-length", str(len(pic)))

  # send the poop
  trans.response().write(pic)
---------------------------

It works!

Is there any reason that this is bad form? I'm concerned about low-level I/O
issues and that sort of thing. I suppose that there's no reason to inherit
from Page, when I could inherit from HTTPServlet. Opinions?

If this is ok, we're planning to implement servlets that cough up flash and
svg based graphs and that sort of thing. Heck, pdf, word, mp3, whatever
should be possible. (I've also got an itch to re-write the mp3 server that I
use [edna.sourceforge.net] in webware)

Thanks.


_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to