title: Read a python rewritten image in Flask
body: <p>I have code using Flask as given below:</p>
  
  <pre><code>app = Flask(__name__,static_url_path='/static')
  @app.route('/')
  def my_form():
      return render_template('my-form.html')
  
  @app.route('/result', methods=['POST'])
  def result():
  
      text = request.form['Name']
      sentiment = generateimage(text)
  
  
  
      return render_template("result.html")
  </code></pre>
  
  <p><strong>my-form.html</strong></p>
  
  <pre><code>&lt;div class="col-lg-1"&gt;&lt;/div&gt;
  &lt;div class="col-lg-10"&gt;
      &lt;form action="http://localhost:5505/result" method="POST"&gt;
          &lt;div class="form-group"&gt;
              &lt;label for="comment"&gt;Text&lt;/label&gt;
              &lt;textarea class="form-control" rows="10" cols="4" id="comment" name="Name"&gt;&lt;/textarea&gt;
          &lt;/div&gt;
          &lt;input type="submit" class="btn btn-info" value="Analyze"&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>result.html</strong></p>
  
  <pre><code> &lt;img src ="/static/fig1.png"/&gt; 
  </code></pre>
  
  <p>What <code>flask.py</code> does is grab the text from <code>my-form</code>, process it and generate an image in a static folder, but when the <code>result.html</code> page loads up it displays the previously generated image and not the most recent one.</p>
  
  <p>How do I solve this issue?</p>
  
  <pre><code>def generateimage(text)
         ######some code######
          plt.savefig('/home/aurora/Desktop/sentiment/static/fig1.png', dpi=dpi)
  </code></pre>