0

I'm trying to write an image with

self.wfile.write(bytes(img.read()))

and it's working fine when I have self.send_header('Content-type','image/png')

but I need 'Content-type','text/html' for other things that I do. I tried

self.wfile.write(bytes("<img alt='Embedded Image' src='data:image/png;base64," + img.read() + "/>", "utf8"))

and I'm getting

TypeError: Can't convert 'bytes' object to str implicitly

jimakos17
  • 905
  • 4
  • 14
  • 33
  • 1
    Do you want to include the images inline, with base64 encoded strings [like this](http://stackoverflow.com/questions/1207190/embedding-base64-images)? I can't imagine that it would work otherwise – chrki Nov 29 '16 at 20:58
  • 1
    `src=` expects link to file - ie. `src="http://example.com/image.png"`, or image bytes in base64. – furas Nov 29 '16 at 21:04
  • Thank you both for your comments, I updated my question. – jimakos17 Nov 29 '16 at 21:21

0 Answers0