title: Flask Download a File
body: <p>I'm trying to create a web app with Flask that lets a user upload a file and serve them to another user. Right now, I can upload the file to the <em>upload_folder</em> correctly. But I can't seem to find a way to let the user download it back.</p>
  
  <p>I'm storing the name of the filename into a database. </p>
  
  <p>I have a view serving the database objects. I can delete them too.</p>
  
  <pre><code>@app.route('/dashboard', methods=['GET', 'POST'])
  def dashboard():
  
      problemes = Probleme.query.all()
  
      if 'user' not in session:
          return redirect(url_for('login'))
  
      if request.method == 'POST':
          delete = Probleme.query.filter_by(id=request.form['del_button']).first()
          db.session.delete(delete)
          db.session.commit()
          return redirect(url_for('dashboard'))
  
      return render_template('dashboard.html', problemes=problemes)
  </code></pre>
  
  <p>In my HTML I have:</p>
  
  <pre><code>&lt;td&gt;&lt;a href="{{ url_for('download', filename=probleme.facture) }}"&gt;Facture&lt;/a&gt;&lt;/td&gt;
  </code></pre>
  
  <p>and a download view :</p>
  
  <pre><code>@app.route('/uploads/&lt;path:filename&gt;', methods=['GET', 'POST'])
  def download(filename):
      return send_from_directory(directory=app.config['UPLOAD_FOLDER'], filename=filename)
  </code></pre>
  
  <p>But it's returning : </p>
  
  <blockquote>
    <p>Not Found</p>
  </blockquote>
  
  <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
  
  <p>I just want to link the filename to the object and let the user download it (For every object in the same view) </p>