Are you saying you want the client to be able to download a fully rendered
HTML document (as opposed to actually displaying the HTML in the browser)?
If so, you can do something like this:
def export():
import cStringIO
html = response.render(dict(test=test, stats=stats))
export = cStringIO.StringIO()
export.write(html)
export.seek(0)
return response.stream(export, attachment=True, filename='export.html')
If that is in the default.py controller, when you request the URL
/myapp/default/export, that will render the /views/default/export.html view
and return the HTML file as an attachment to be downloaded. If you want to
render a different view, you can specify the relative path to the view file
as the first argument to response.render().
Anthony
On Thursday, October 16, 2014 7:28:44 AM UTC-4, CrC Nommack wrote:
>
> Hi everybody.
> First of all thank you very much for your help it would be really
> appreciated.
>
> Well this is "my problem".
> I have a custom view and I want it to be save as a html file by the client.
> But I don't know how to do it!!!
>
> I tried:
> with open(filename, 'wb') as f:
> f.write(response.render('controller/export.html',dict(test=test,
> stats=stats)))
>
> Works but it saves the file in the server :(
>
> How can I make it? Any ideas?
>
> Thank you very much in advance.
> Kind regards
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout.