title: Serve a profile picture whose path is stored in database with Flask Python
body: <p>I am trying to serve a profile picture whose path is stored in the sqlalchemy database. </p>
  
  <p>The snippet code is :</p>
  
  <pre><code>@employees.route('/upload-picture/&lt;full_name&gt;', methods=['GET', 'POST'])
  @login_required
  def upload(full_name):
      if not current_user.is_employee:
          abort(403)
      borrower = Borrower.query.filter_by(full_name=full_name).first()
      if request.method == 'POST' and 'photo' in request.files:
      profile_pic = photos.save(request.files['photo'])
          borrower.profile_pic = profile_pic
          db.session.add(borrower)
          db.session.commit()
      return render_template('employees/borrower.html', borrower=borrower)
  
  @employees.route('/uploaded_profile_pic/&lt;filename&gt;')
  @login_required
  def uploaded_profile_pic(filename):
      if not current_user.is_employee:
          abort(403)
      return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
  </code></pre>
  
  <p>My template file is as follows:</p>
  
  <pre><code>  {% if borrower.profile_pic %}
          &lt;img src="{{ url_for('employees.uploaded_profile_pic', filename = borrower.profile_pic)}}" /&gt;
      {% else %}
      &lt;form action="{{url_for('employees.upload', full_name=borrower.full_name)}}" method="POST" enctype="multipart/form-data"&gt;
      &lt;input type="file" name="photo"&gt;&lt;br /&gt;&lt;br /&gt;
      &lt;input type="submit" value="Upload"&gt;
      &lt;/form&gt;
      {% endif %}
  </code></pre>
  
  <p>The problem is i keep getting a broken image on the template.</p>