Created
May 9, 2014 08:41
-
-
Save aminamid/cccc8b2eefdec279be3b to your computer and use it in GitHub Desktop.
Python snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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