def get_coffee_image(coffee_id):
"""Gets the image attached to the coffee"""
coffee_int_id = int(coffee_id)
coffee = memcache.get("coffee_image_{}".format(coffee_int_id))
if not coffee:
coffee = Coffee.get_by_id(coffee_int_id)
memcache.set("coffee_image_{}".format(coffee_int_id), coffee)
if coffee:
if coffee.image:
return send_file(io.BytesIO(coffee.image))
return app.send_static_file('coffee.png')
评论列表
文章目录