title: Python Flask project download excel error,
body: <p>Every time this is downloading the excel with same content , can someone please help me to understand if this is something related to caching or session issue and how we can resolve it.</p>
  <pre><code>app = Flask(__name__)
  class Datastore():
      item = None
  data = Datastore()
  @app.route('/', methods=['GET', 'POST'])
  def index():
      if request.method == 'POST':
          key = request.form['key']
          data.item = key
          return render_template('index.html', key=key)
      else:
          return render_template('index.html')
  
  
  @app.route(&quot;/download&quot;)
  def download():
      key = str(data.item)
      fn = key + &quot;xlsx&quot;
      # Create Workbook
      workbook = xlsxwriter.Workbook(fn)
      worksheet = workbook.add_worksheet()
      worksheet.write(0, 0, key)
      workbook.close()
      return send_file(fn, mimetype='application/vnd.ms-excel')    
  if __name__ == &quot;__main__&quot;:
      app.run(debug=True)
  
  
  #index.html:-
  
  &lt;form  action=&quot;{{ url_for('index') }}&quot; method=&quot;post&quot; &gt;
      &lt;input type=&quot;text&quot; id=&quot;key&quot; placeholder=&quot;provide key ..&quot; name=&quot;key&quot;&gt;
      &lt;button type=&quot;submit&quot;&gt;Find&lt;/button&gt;
  &lt;/form&gt;
  
  {% if ( key is defined ) %}
      {{ key }}
  {% endif %}
  &lt;/br&gt;
  &lt;a href=&quot;/download&quot;&gt;Click Here&lt;/a&gt; to download below report. ```
  </code></pre>