0

私は GAE と Python の初心者です。

ユーザーがアプリケーション用に大量の html ファイルを作成する GAE/Python アプリがあります。ファイルの内容は、(フォルダーとファイル名と共に) blob 型として ndb の種類に格納されます。私はそのようなファイルレコードを何百も持っています。

Web ページに blob フィールドを表示するにはどうすればよいですか (タグは URL を必要とします)。

提案をありがとう。

4

1 に答える 1

1

これはどうですか?

レンプレート:

Photo: <img src="/image?id={{someid}}" />

そして、ビューで(にマップされます/image):

class GetImage(webapp.RequestHandler):
    def get(self):
        # retrieve the image from the blobstore using self.request.get('id')
        img = ... # omitted
        self.response.headers['Content-Type'] = 'image/png'
        self.response.out.write(img)


urls = [('/image', GetImage),]
application = webapp.WSGIApplication(urls)
if __name__ == "__main__":
    run_wsgi_app(application)
于 2012-08-30T04:26:33.343 に答える