0

I am trying to embed an image inside HTML which is generated by an azure function. when I run it in localhost I am able to see the image, but when I convert that to an azure function it throws a broken thumbnail image.iam using matplotlib to save the plot

plt.savefig(f'{basepath}/plot.png')

this will save it to a temporary path and then I am using it inside my HTML content

<div class="image">
   <img src="""f'../{basepath}/plot.png'""">
</div>

on inspecting the page also iam able to see the correct path, though not the image enter image description here

rahul knair
  • 103
  • 11

1 Answers1

0

converting the image to a base encoded version

 encoded = base64.b64encode(tmpfile.getvalue()).decode('utf-8')

and calling that inside the HTML worked for me

 <img src="""f'data:image/png;base64,{encoded}'""">
rahul knair
  • 103
  • 11