2

I have a Flask form to query a database to retrieves entries by country and stores the results as a results object. Then, these entries are displayed using a jinja2 template I named list.html by passing results using render_template.

Now, I want to dynamically create a text file (or tabbed-delimited file for example) containing these retrieved entries so that it can be downloaded.

First, how do you dynamically create such a text file in Flask? Then, how do you create a link to download this dynamically-created file and include it in the jinja2 template?

kentwait
  • 1,969
  • 2
  • 21
  • 42
  • 2
    Similar question to http://stackoverflow.com/questions/12166970/in-python-using-flask-how-can-i-write-out-an-object-for-download – marven Nov 22 '16 at 09:23
  • This is useful but how do I pass the `results` object from the view that retrieves and displays the results to the view that creates the text file? – kentwait Nov 22 '16 at 09:46
  • you can generate this file in your `views` rather to cluttering with `template`. it will increase the complexity. the above example should help to attain. – Nava Nov 22 '16 at 09:50

0 Answers0