title: Flask: Download a csv file on clicking a button
body: <p>I just got started with Flask/Python. What I want to achieve is that I have a download button in my HTML and it calls the following function:</p>
  
  <pre><code>function downloadPlotCSV() {
          $.ajax({
              url: "/getPlotCSV",
              type: "post",
              success: function(data) {
                  dataPlot = JSON.parse(data);
                  console.log(dataPlot);
              }
          });
      }
  </code></pre>
  
  <p>The incomplete flask code is:</p>
  
  <pre><code>@app.route('/getPlotCSV', methods = ['POST'])
  def plotCSV():
      data = open("outputs/Adjacency.csv")
  </code></pre>
  
  <p>The problem I am facing is that I cannot find a way to download this csv file or return it as a JSON string so I can download it using Javascript. Any idea how I can send it as JSON or maybe download it via Flask itself? What's the best way?   </p>