【问题标题】:google app engine: display images in place谷歌应用引擎:就地显示图像
【发布时间】:2013-08-09 04:47:48
【问题描述】:

我正在关注Google App Engine 2e 编程中的 Blobstore 示例。

在该示例中,home.html 提供了指向用户上传图片的链接,当点击这些链接时,图片会显示在另一个新窗口中。有什么方法可以在适当的位置显示这些图像?网上有例子吗?

以下是书中的一些代码段: 在 home.html 中,提供这些图片链接的代码是:

<a href="/view?key={{ upload.key() }}"> {{upload.blob.filename}} </a>

请求处理程序中处理图像查看请求的代码:

class ViewHandler(blobstore_handlers.BlobstoreDownloadHandler):
def get(self):
    upload = get_upload(self.request.params.get('key'),
                        users.get_current_user())
    if not upload:
        self.error(404)
        return

    self.send_blob(upload.blob)

这样,当点击home.html中的链接时,会跳转到一个新窗口并显示图片。 我想找到一些方法来在适当的位置而不是在新窗口中显示图像。

【问题讨论】:

  • 信息太少,无法回答。提供更多信息(您使用哪种语言,粘贴一些代码)。

标签: python google-app-engine blobstore


【解决方案1】:

我使用 image.get_serving_url() 在用户上传图像时生成缩略图并将其存储在数据存储中。然后我只需要使用

<img src=""> 

在 html 中显示它。

【讨论】:

    猜你喜欢
    • 2012-03-09
    • 1970-01-01
    • 1970-01-01
    • 2013-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-19
    • 1970-01-01
    相关资源
    最近更新 更多