In index.html, I link to an index.js file. On click one button, js sends a request to Flask back end. The backend returns a static file path: 'data/Sharon_4.png'. I want to render it in HTML using the following function, but it doesn't work. To simplify it, I replaced the URL with a specific URL as the following, not as a variable. It still doesn't work.
function test(){
var mvt = document.getElementById('movieThumbnail')
var ig = document.createElement('img')
ig.src = `{{url_for('static', filename='data/haron_4.png')}}`
mvt.append(ig)
}
In HTML the tag seems right <img src="{{url_for('static', filename='data/Sharon_4.png')}}">
If I put this tag directly in HTML or in in-page script, it works. But here using url_for in js it doesns't.