I am using python 3 & I have this code, trying to get base64 out of stream and returnn as json - but not working.
stream = BytesIO()
img.save(stream,format='png')
return base64.b64encode(stream.getvalue())
in my view, I have:
hm =mymap()
strHM = hm.generate(data)
return HttpResponse(json.dumps({"img": strHM}),content_type="application/json" )
getting error is not JSON serializable. base64.b64encode(stream.getvalue()) seems giving bytes

所有评论(0)