title: Serving Images using Tornado without File I/O
body: <p>I'm trying to serve a webcam image using Tornado library but the only way I found is to save the image first and then return the image name.</p>
  
  <p>Is there a way to serve the image without saving to disk?</p>
  
  <pre><code>import tornado.ioloop
  import tornado.web
  import pygame.camera
  import pygame.image
  from time import time
  from io import StringIO
  
  pygame.camera.init()
  cam = pygame.camera.Camera(pygame.camera.list_cameras()[0])
  cam.start()
  
  class MainHandler(tornado.web.RequestHandler):
      def get(self):
  
  
          img = cam.get_image()
          name = str( round( time() ) )
          name = name + '.jpg'
          pygame.image.save(img, name)
  
  
          self.write('&lt;img src="' + name + '"&gt;')
  
  
  
  application = tornado.web.Application([
      (r"/", MainHandler),
      (r'/(.*)', tornado.web.StaticFileHandler, {'path': ''})
  ])
  
  if __name__ == "__main__":
      application.listen(8888)
      tornado.ioloop.IOLoop.instance().start()
  </code></pre>