1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Request handler to display an image from Google Cloud Storage."""
12 from common import cloud_bucket
13 from common import constants
18 class ImageHandler(webapp2.RequestHandler):
19 """A request handler to avoid the Same-Origin problem in the debug view."""
22 """Handles get requests to the ImageHandler.
25 file_path: A path to an image resource in Google Cloud Storage.
27 file_path = self.request.get('file_path')
31 bucket = gs_bucket.GoogleCloudStorageBucket(constants.BUCKET)
33 image = bucket.DownloadFile(file_path)
34 except cloud_bucket.FileNotFoundError:
37 self.response.headers['Content-Type'] = 'image/png'
38 self.response.out.write(image)