import base64
import requests
def get_as_base64(url):
return base64.b64encode(requests.get(url).content)
Display image stored as binary blob in template
from base64 import b64encode
@app.route("/show/<int:id>")
def show(id):
obj = A.query(A.id == id).fetch(1)[0]
image = b64encode(obj.image).decode("utf-8")
return render_template("show_a.html", obj=obj, image=image)
<p>{{ obj.x }}<br/>
{{ obj.y }}</p>
<img src="data:;base64,{{ image }}"/>
No comments:
Post a Comment