The logic for pulling an image out of the datastore is stored in the
image_sharing.py file....
class ImageSharingServeImage(webapp.RequestHandler):
"""Handler for dynamically serving an image from the datastore.
Very simple - it just pulls the appropriate data out of the
datastore
and serves it.
"""
def get(self, display_type, pic_key):
"""Dynamically serves a PNG image from the datastore.
Args:
type: a string describing the type of image to serve (image or
thumbnail)
pic_key: the key for a Picture model that holds the image
"""
image = db.get(pic_key)
if display_type == 'image':
self.response.headers['Content-Type'] = 'image/png'
self.response.out.write(image.data)
elif display_type == 'thumbnail':
self.response.headers['Content-Type'] = 'image/png'
self.response.out.write(image.thumbnail_data)
else:
self.error(500)
self.response.out.write(
'Couldn\'t determine what type of image to serve.')