title: Pass matplotlib graph to HTML template (Flask)
body: <p>Here's the section of code where i'm generating a plot:</p>
  
  <pre><code>graph = df.plot(x='date', y='close')
  fig = graph.get_figure()
  filepath = 'static/images/graph.png'
  fig.savefig(filepath)
  
  return render_template('search_result.html')
  </code></pre>
  
  <p>I'm defining my static path in the top of my Flask file like this:</p>
  
  <p><code>app = Flask(__name__, static_folder='path/to/static/folder')</code></p>
  
  <p>Here's my file directory setup:</p>
  
  <pre><code>Main Folder
    - Static
      -- Images
        --- Graph.png
    - Templates
    - app.py
  </code></pre>
  
  <p>In my HTML template, i'm currently just doing this:</p>
  
  <p><code>&lt;img src="{{ url_for('static', filename = 'graph.png') }}"&gt;</code>
  ... however it's only displaying an older image. I'm rewriting over the image every time the function is called. </p>
  
  <p>I understand passing variables to HTML using jinja however i'm unsure how to do it with an image path.</p>
  
  <p>Could anyone help me out?</p>