-2

I have to use an image that is stored in the directory uploaded/images in Html/javascript file using Flask.


<img id="img" src= "">
<h1 id="file_path" style="visibility:hidden">{{ file_path }}</h1>

and js

var file_path = "../uploaded/images/" + document.getElementById("file_path").innerHTML;
document.getElementById("img").setAttribute("src",file_path)

And the directory structure looks like this:

predict.html contains those codes (above).

The image to be shown is inside uploaded/images.

home.py is the flask app.

1 Answers1

-1

Possible duplicate of: What is the correct way to serve/access media files in Flask

Accepting uploaded media files locally is

  • Very process-intensive.
  • Dangerous, security-wise

Please make sure to put in enough checks to validate the content, and if you can, serve them off-site, on a different domain.

nigel239
  • 1,485
  • 1
  • 3
  • 23