I have a python web-application running inside the Google App Engine.
The application creates on user-demand a string and I want the string to be send to the browser client (application/octet-stream?) as a file.
How can i realize this?
I have a python web-application running inside the Google App Engine.
The application creates on user-demand a string and I want the string to be send to the browser client (application/octet-stream?) as a file.
How can i realize this?
Setting a content-disposition: attachment
header will cause most browsers to download whatever you send them as a file. Safari sometimes ignores it.
If you're using App Engine's own, simple webapp framework, the simplest approach is to have as the get
method of your request handler object something like:
def get(self):
thestring = 'helloworld' # or however else it's synthesized;-)
self.response.headers.add_header(
'content-disposition', 'attachment', filename='hw.txt')
self.response.out.write(thestring)
Of course, you can use more sophisticated approaches, if you have other different goals, but this meets your goal as stated.