Skip to content

Instantly share code, notes, and snippets.

@aminamid
Created May 9, 2014 08:41
Show Gist options
  • Save aminamid/cccc8b2eefdec279be3b to your computer and use it in GitHub Desktop.
Save aminamid/cccc8b2eefdec279be3b to your computer and use it in GitHub Desktop.
Python snippet
class FileHandler(tornado.web.RequestHandler):
def get(self):
self.set_header('Content-Type', "text/csv")
self.set_header('Content-Disposition',
"attachment; filename=\"{}\"".format(filename))
self.set_header('Content-Length', os.path.getsize(filename))
with open(filename, 'rb') as fp:
self.write(fp.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment