title: How to pass pandas dataframe to button in web for download file(.csv or .xlsx) with flask, Python 2.7
body: <p>My web application has visualization function for user see chart(Average, Standard Deviation) by <code>from ...day</code> <code>to ...day</code>(Start Date to End Date), where(Production line) then request to SQL for connect database. <strong>This is visualization form.</strong> :</p>
  
  <p><a href="https://i.stack.imgur.com/6BmEU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6BmEU.png" alt="enter image description here"></a></p>
  
  <p>After request of user my web app will show about 31 charts and I add 3 buttons for download file every chart in web look like this. (<strong>example. number 1,2 of chart</strong>) :  </p>
  
  <p><a href="https://i.stack.imgur.com/gRuFt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gRuFt.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/9KOjI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9KOjI.png" alt="enter image description here"></a></p>
  
  <p>And this is <strong>my javascript for create chart and , etc</strong> in file <code>.html</code> (spc_chart.html) <strong>but</strong> don't yet pass dataframe to <code>.html</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/AETxb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AETxb.png" alt="enter image description here"></a></p>
  
  <p>I have all pandas dataframe of Avg Chart Data, Std Chart Data, Raw Data(use calculate for Avg,Std) in 3 arrays(name is: ChartDataAvg, ChartDataStd, RawData). </p>
  
  <p>I just know that how to download file must will add <code>href="/..."</code> at each of button and set <code>@app.route('/...')</code> in python then send SQL to each def of <code>@app.route('/...')</code> and pass dataframe to web after calculated. ref(<a href="https://stackoverflow.com/questions/30024948/flask-download-a-csv-file-on-clicking-a-button">Flask: Download a csv file on clicking a button</a>) <strong>But</strong> I don't know how to pass SQL request of user from def in another <code>@app.route(/...)</code>. </p>
  
  <p><strong>Is there any way to pass all pandas dataframe to button for download file in each of the chart 1, 2, 3,... or send SQL to def in another <code>app.route</code>???</strong></p>