def _file_response(self, app_root, file_path):
     file_path = 'index.html' if not file_path\
     else os.path.normpath(file_path)
     if os.path.split(file_path)[0] == '..':
         return HTTPForbidden()
     full_path = os.path.join(app_root, file_path)
     if not os.path.isfile(full_path):
         return HTTPNotFound()
     response = routine.file_response(full_path)
     response.headers.update(self.access_control_headers)
     return response
 def sdk(self, request, response, file_path):
     local_path = 'js/dist/' + file_path
     if os.path.isfile(local_path):
         response = routine.file_response(local_path)
         response.headers.update(self.access_control_headers)
         return response
     url = self.sdk_url_pattern.replace('{path}', file_path)
     data = urllib2.urlopen(url)
     head = data.info()
     body = data.read()
     response.headers.update({'Content-Type': head['Content-Type']})
     response.headers.update(self.access_control_headers)
     response.body = body
     return response