def process(self, filename): m = mimetypes.guess_type(filename, False) if m is not None: flag = 'rb' if m[0].startswith('image') else 'r' return dict( content=read_file(filename, flag), headers=[ ('Content-Type', m[0]) ] ) else: return dict(content=read_file(filename))
def process(self, filename): json = os.path.basename(filename) json = json[:json.rfind('.') + 1] + 'json' json = os.path.abspath( os.path.join(self.handler.config['options'].json_path, json)) data = None if os.path.isfile(json): data = cyclone.escape.json_decode(read_file(json)) loader = cyclone.template.Loader(os.path.dirname(filename)) return dict(content=loader.load( os.path.basename(filename)).generate(data=data), headers=[('Content-Type', 'text/html')])
def process(self, filename): json = os.path.basename(filename) json = json[:json.rfind('.') + 1] + 'json' json = os.path.abspath( os.path.join(self.handler.config['options'].json_path, json) ) data = None if os.path.isfile(json): data = cyclone.escape.json_decode(read_file(json)) loader = cyclone.template.Loader(os.path.dirname(filename)) return dict( content=loader.load(os.path.basename(filename)).generate(data=data), headers=[ ('Content-Type', 'text/html') ] )