Skip to navigation
How to serve asynchronously a in memory png file with a tornado RequestHandler
15.09.15
class Frames(tornado.web.RequestHandler): @tornado.gen.coroutine def get(self): img = Image.open('foo.png') filename = 'foobarfoo.png' o = io.BytesIO() img.save(o, format="PNG") s = o.getvalue() self.set_header("Content-type", "image/png") self.set_header('Content-length', len(s)) self.set_header('Content-Disposition', 'attachment; filename='+filename+'') self.write(s)
http://qnundrum.com/question/1248825
Reply
Anonymous
Information Epoch 1732581364
Live free or die.
Home
Notebook
Contact us