2

My images of plots won't display. I store them separately in "uploads" directory (not static nor its sub).

@app.route('/job/<job_id>')
def get_job(job_id):
    directory_name = db.get(job_id)
    if directory_name is False:
        abort(404)

    return render_template('job.html', directory_name=directory_name)

Im passing directory_name to the html:

<html>
  <body>
    <img src="{{url_for('send_image', directory_name=directory_name)}}" >
  </body>
</html>

Which refers to other view that should browse my directories.

@app.route('/uploads/<directory_name>/plot.png')
def send_image(directory_name, job_id):
    return send_from_directory("uploads", directory_name + "plot.png")

However i still get nothing. What I am doing wrong? Is "static" the only directory that flask can handle? enter image description here

mikazz
  • 159
  • 1
  • 11
  • Does this answer your question? [How to serve static files in Flask](https://stackoverflow.com/questions/20646822/how-to-serve-static-files-in-flask) – Joe Apr 24 '20 at 14:15
  • From simple to complex to figure out where the problem is: first, display some image on a fixed HTML, then try to call a specific image. – Joe Apr 24 '20 at 14:17

0 Answers0