title: Best way to create a download link for a file in Flask?
body: <p>In my project, when a user clicks a link, an AJAX request sends the information required to create a CSV. The CSV takes a long time to generate and so I want to be able to include a download link for the generated CSV in the AJAX response. Is this possible? </p>
  
  <p>Most of the answers I've seen return the CSV in the following way:</p>
  
  <pre><code>return Response(
          csv,
          mimetype="text/csv",
          headers={"Content-disposition":
                   "attachment; filename=myplot.csv"})
  </code></pre>
  
  <p>However, I don't think this is compatible with the AJAX response I'm sending with:</p>
  
  <pre><code>return render_json(200, {'data': params})
  </code></pre>
  
  <p>Ideally, I'd like to be able to send the download link in the params dict. But I'm also not sure if this is secure. How is this problem typically solved?</p>