def image(slug): ''' Show a single image give the safe url key passed in via the URL ''' context = { 'image': Image.entity_for_urlsafe_key(slug), 'base_url': BASE_URL, 'metadata': SiteMetadata.get() } return render_template('image.html', context=context)
def index(): logging.info('attempting to apply tags') data = json.loads(request.get_data()) image_url_safe_key = data.get('key') bucket_name = data.get('bucketname') # Attempt to tag the image via the image API. try: img = Image.entity_for_urlsafe_key(image_url_safe_key) img.tags = get_tags_from_image(bucket_name) img.put() except HttpError as e: if 'it is disabled' in e: logging.error('Vision API is not enabled') return "Success!", 200