これは私がそれを行う方法です、それはフラスコにあります、それにもかかわらずそれはこのようにpythonです、あなたは画像を表示するためにリクエストハンドラーを作成します。
したがって、ajaxを介して画像を取得するために必要なのは、提供される画像IDを取得することだけです。シンプルで、サイズもその場で操作できます
from flask import request
from google.appengine.api import taskqueue, images, mail
from google.appengine.ext import db
@app.route('/image/<img_id>')
def imgshow(img_id):
imageuse = Image.all().filter("image_id =", img_id).get()
if imageuse:
response = Response(response=imageuse.content)
#you can use any type over here
response.headers['Content-Type']='image/png'
return response
else:
return
これは私がサイズを操作するために行うことです
@app.route('/thumb/<img_id>')
def thumbshow(img_id):
imageuse = Image.all().filter("image_id =", img_id).get()
if imageuse:
thbimg = images.resize(imageuse.content, 80)
response = Response(thbimg)
response.headers['Content-Type']='image/png'
return response
else:
return
それが役立つことを願っています