title: How can I send a plt/picture (from matplotlib import pyplot as plt) from Flask to render/show/keep in React?
body: <p>How can I send a plt/picture (from matplotlib import pyplot as plt) from Flask to render/show/keep in React?</p>
  
  <p>I just took the relevant part from python and react, instead of having all the code here.</p>
  
  <p>main.py</p>
  
  <pre><code>plt.savefig("test100.png", transparent=True, bbox_inches='tight', dpi=150) //Here
  return send_file('test100.png', mimetype='image/jpg') //Here
  </code></pre>
  
  <p>kmeans.js</p>
  
  <pre><code>axios.post(`/kmeans`, {
       cart: this.state.cart
  }).then(function (response) {
      console.log(response) // Here
  })
  </code></pre>
  
  <p>I was searching online for example, and I found, but seems to be some depreciated methods that does not work anymore (for example, <a href="https://stackoverflow.com/questions/56867734/how-to-get-an-image-from-flask-api-in-react-native#">how to get an image from flask api in react native</a> which results in TypeError: Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided. at KMeansAlgorithm.js:59) . Not sure I am doing it right in flask as well.</p>