Google App Engine Python Download File
I am trying to figure out a way where I can create a tab-delimited file containing data from user-defined fields and allow the user to download that file on google app engine. The
Solution 1:
Sure there is! You can output your data as csv
, for instance. All you need to do is to change the Content-Type
header.
It's something like this:
class Test(webapp.RequestHandler):
def get(self, upload_type):
self.response.headers['Content-Type'] = 'text/csv'
self.response.out.write(','.join(['a', 'cool', 'test']))
Solution 2:
In addition to jbochi's answer, you can also add a Content-Disposition header to save using a particular filename.
self.response.headers['Content-Disposition'] = "attachment; filename=fname.csv"
Post a Comment for "Google App Engine Python Download File"