title: How to download an uploaded CSV file as excel file
body: <p>Here is my view function.</p>
  <pre><code>from flask import Flask
  from config import Config
  app = Flask(__name__)
  
  UPLOAD_FOLDER = 'filepath'
  app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
  
  @app.route('/uploader', methods=['GET', 'POST'])
  @login_required
  def uploader():
      f = request.files['file']
      if not f:
          return &quot;No file&quot;
  
      stream = io.StringIO(f.stream.read().decode(&quot;UTF8&quot;), newline=None)
      file = pd.read_csv(stream)
      return render_template(&quot;uploader.html&quot;, data=file.to_html())
  </code></pre>
  <p>This is the index HTML page for uploading where I add the form code(index.html).</p>
  <pre><code>&lt;form action = &quot;/uploader&quot; method = &quot;POST&quot;
       enctype = &quot;multipart/form-data&quot;&gt;
       &lt;input type = &quot;file&quot; name = &quot;file&quot; /&gt;
       &lt;br&gt;
       &lt;input type = &quot;submit&quot;/&gt;
  &lt;/form&gt;
  </code></pre>
  <p>And this is where I am able to see the uploaded CSV in HTML (uploader.html).</p>
  <pre><code>{% extends &quot;base.html&quot; %}
  
  {% block content %}
  
  {{ data | safe }}
  
  {% endblock %}
  </code></pre>
  <p>Now, I want to download the uploaded CSV file as excel. Is there any approach that I can follow? Should I add a download link on the uploader.html file or the index.html. And for either of those, how to write the view function code? The uploader view function already has the uploaded CSV file in its code. Is there any way I can leverage that?</p>
  <p>I was also thinking about sharing the file object from the uploader view function with the new downloader view function that I haven't created yet. But is there any way to do that?</p>