I\'m tying to get an image attachment from couchdb using flask & python then pass the image to imgurl.html to be displayed. The problem is that I\'m only get this:
Before I saw @SHC's answer I managed to come up with a solution my self. What I did was retrieve the name of the attachment and then append that to the end of a url like i.e "http:localhost:5984/dbName/docId/attachmentName". I passed that url to the html img src and it worked then. Thank you you @SHC for your answer. sorry I didnt see it sooner.
One option could be to base64 encode the image data returned from couchdb and pass the encoded data as a string to the template where you can render it. E.g.
img = db.get_attachment('2', 'aboutme.jpg', default=None).read()
img_b64 = base64.b64encode(img)
def imgurl():
return render_template('imgurl.html', doc = img_b64)
Then in the template:
<img src="data:image/png;base64,{{ doc }}" id="imgslot" >
Another option depending on your security model could be to serve the image directly from couchdb by adding the image url to the image tag, e.g. Getting url for an attachment