import StringIO

def index():
    strIO = StringIO.StringIO()
    strIO.write('Hello from Dan Jacob and Stephane Wirtel !')
    strIO.seek(0)
    return response.stream(strIO, attachment=True, filename="testing.txt")

Anthony

On Wednesday, May 15, 2013 12:41:07 PM UTC-4, Calvin wrote:
>
> I was searching for the above functionality and found a solution using 
> Flask and StringIO as below (short code snippet attached for convenience). 
> Is there a way to do the same with web2py (without resorting to b64 
> encoding...)?
>
>
>
> http://flask.pocoo.org/snippets/32/
>
> #!/usr/bin/env python
> # Thanks to Dan Jacob for a part of the code !
> from flask import Flask, send_fileimport StringIO
> app = Flask(__name__)
> @app.route('/')def index():
>     strIO = StringIO.StringIO()
>     strIO.write('Hello from Dan Jacob and Stephane Wirtel !')
>     strIO.seek(0)
>     return send_file(strIO,
>                      attachment_filename="testing.txt",
>                      as_attachment=True)
>         app.run(debug=True)
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to