-1

My goal is to send an image to front-end via Flask REST API. The image is generated by matplotlib. What are the best tools and libraries to handle this?

  • you can try the following: ```import base64 import io pic_IObytes = io.BytesIO() plt.savefig(pic_IObytes, format='png') pic_IObytes.seek(0) pic_hash = base64.b64encode(pic_IObytes.read()) response = app.response_class(response="data:image/png;base64,{}".format(pic_hash),status=200,mimetype="image/png") return response ``` not sure if it will work – Mohammad Kamrul Hasan May 15 '22 at 18:00

0 Answers0