Close, but not quite right.
self.response.headers["Content-Type"] = "application/x-download"
self.response.headers["Content-Disposition"] =
"attachment;filename=d.txt"
The first line tells the browser that you want it to download, period.
The second line shows you that you do not want quotes around the
filename.
On Sep 11, 2009, at 2:36 AM, dingle wrote:
>
> I want to make my web app to provide download a file.
>
> A simple example is like that:
>
> ############################################
> class MainHandler(webapp.RequestHandler):
> def get(self):
> self.response.headers['Content-Type'] = "html/text"
> self.response.headers['Content-Disposition'] =
> 'attachment;filename="d.txt"'
> self.response.out.write("abcd")
>
> def main():
> application = webapp.WSGIApplication([('/d', MainHandler)],
> debug=True)
> wsgiref.handlers.CGIHandler().run(application)
>
> if __name__ == '__main__':
> main()
> ##############################################################
>
> It should download a file d.txt with content "abcd"
>
> I tried the code in localhost, it works well.
> I updated it to appspot.com, it failed.
> From IE, an error "Internate Explorer cannot donwload d from ...."
> happened.
>
> So does appspot.com support to download a file? Or anything I made
> mistake code?
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---