title: Display image with variable and URL_FOR - Flask
body: <p>My target is to display an image on a website, with Flask.</p>
  <p>The image is in :</p>
  <pre><code>/static/img/articles
  </code></pre>
  <p>The image name is : &quot;43.jpg&quot;</p>
  <p>Hardcoding it is perfectly working :</p>
  <pre><code>&lt;img src=&quot;{{ url_for('static', filename='img/articles/43.jpg') }}&quot; alt=&quot;no picture&quot;&gt;
  </code></pre>
  <p>However, i need the path to be dynamic (the image is 43 today, maybe 17 tomrrow and 58 after tomorrow).</p>
  <p>I tried everything, for example this :</p>
  <p>last_id_jpg = r&quot;img/article/43.jpg&quot;</p>
  <pre><code>return render_template(&quot;index3.html&quot;,
                          last_id_jpg = last_id_jpg
                         )
  </code></pre>
  <p>with :</p>
  <pre><code>&lt;img src=&quot;{{ url_for('static', filename=last_id_jpg) }}&quot; alt=&quot;no picture&quot;&gt;
  </code></pre>
  <p>or :</p>
  <pre><code>&lt;img src=&quot;{{ url_for('static', filename='last_id_jpg') }}&quot; alt=&quot;no picture&quot;&gt;
  </code></pre>
  <p>But can't find the path to the designed image (the webpage displays &quot;no picture&quot;). I made some researches and <a href="https://stackoverflow.com/questions/47871185/python-flask-url-for-static-with-variable">everything seems OK</a></p>
  <p>What is wrong in my code ?</p>