def get(self): """Respond to HTTP GET methods.""" if not custom_module.enabled: self.error(404) return path = self.request.path if path.startswith('/'): path = path[1:] path = os.path.normpath(path) if os.path.basename(os.path.dirname(path)) != 'assets': self.error(404) return resource_file = os.path.join(appengine_config.BUNDLE_ROOT, path) mimetype = mimetypes.guess_type(resource_file)[0] if mimetype is None: mimetype = 'application/octet-stream' try: sites.set_static_resource_cache_control(self) self.response.status = 200 stream = open(resource_file) content = stream.read() self.response.headers['Content-Type'] = mimetype self.response.write(content) except IOError: self.error(404)
def get(self): css = [] for tag_name, tag_class in tags.get_tag_bindings().items(): css.append( '.yui-toolbar-%(tag_name)s > .yui-toolbar-icon {' ' background: url(%(icon_url)s) !important;' ' background-size: 100%% !important;' ' left: 5px;' '}' % { 'tag_name': tag_name, 'icon_url': tag_class().get_icon_url()}) # Ensure this resource is cacheable. sites.set_static_resource_cache_control(self) self.response.headers['Content-Type'] = 'text/css' self.response.out.write('\n'.join(css))