serve raw jpeg data from a handler

6 views
Skip to first unread message

jvanasco

unread,
Apr 27, 2006, 5:40:02 PM4/27/06
to TurboGears
i need to serve raw jpeg data from a handler that generates images on
the fly, to implement a captcha system

unfortunately, this is the documention on this sort of thing:

http://groups.google.com/group/turbogears/browse_frm/thread/2b175032389df8fc/15b36d672b403510?lnk=st&q=cherrypy+raw&rnum=3#15b36d672b403510

does anyone have a clue on how I can achieve this?

serveFile in cherrypy is the closest to anything that will work, but
i'll have to butcher it to work on raw data.

anyone have another idea?

jvanasco

unread,
Apr 27, 2006, 5:51:01 PM4/27/06
to TurboGears
to answer myself...

@expose()
def captcha(self,**data):
captchaInstance = TG_Captcha(captcha_seed='email_address')
cherrypy.response.headerMap['Content-Type'] = 'image/jpeg'
return captchaInstance.generate_image().render_img()

Andrew Grover

unread,
Apr 27, 2006, 7:19:03 PM4/27/06
to turbo...@googlegroups.com

Very cool!

jvanasco

unread,
Apr 27, 2006, 10:09:11 PM4/27/06
to TurboGears
very cool indeed, as this is kind of not explicit in the TG or CherryPY
docs.

Reply all
Reply to author
Forward
0 new messages