Google app engine 在GAE上使用jinja2显示图像

Google app engine 在GAE上使用jinja2显示图像,google-app-engine,jinja2,Google App Engine,Jinja2,我有一个图像数据库。我想使用jinja2模板显示数据库中的所有图像 我按如下方式发送数据库对象: class Default_tiles(db.Model): name = db.StringProperty() image = db.BlobProperty(default=None) class MainPage(webapp2.RequestHandler): def get(self): # get all the default tiles in the da

我有一个图像数据库。我想使用jinja2模板显示数据库中的所有图像

我按如下方式发送数据库对象:

class Default_tiles(db.Model):
  name = db.StringProperty()
  image = db.BlobProperty(default=None)


class MainPage(webapp2.RequestHandler):
  def get(self):

    # get all the default tiles in the database 
    default_tiles_query = Default_tiles.all()
    defaultTiles = default_tiles_query.fetch(10)

    template_values = {
        'defaultTiles': defaultTiles  # contain all the defaut tiles to be displayed 
    }

    template = jinja_environment.get_template('index.html')
    self.response.out.write(template.render(template_values))
jinja2模板用于在默认\u平铺中显示每个对象中的每个图像:

<body>  
  {% for defaultTile in defaultTiles %}
    {{ defaultTile.image }}
  {% endfor %}
</body>
运行此操作时,我会收到以下错误日志:

File/Users/jamiefearon/Desktop/Development/My Programs/GAE全功能网站,带有css、javascript和images/index.html,第24行,顶级模板代码 {{defaultTile.image} UnicodeDecodeError:“ascii”编解码器无法解码位置0中的字节0x89:序号不在范围128中

我怀疑我对{{defaultTile.image}行做了什么错误


谢谢大家的帮助。

您不能只是将二进制数据放入html并显示图像,您需要使用元素显示图像


您需要使用处理程序提供图像,或者使用显示图像

您不能只是将二进制数据放入html并显示图像,您需要使用元素显示图像


您需要使用处理程序提供图像,或者使用显示图像

多谢各位。你知道我可以看哪些例子来更好地理解如何做到这一点吗?i、 e如何在数据存储中显示数据库中的所有图像谢谢。你知道我可以看哪些例子来更好地理解如何做到这一点吗?i、 e如何在数据存储中显示数据库中的所有图像