예제 #1
0
파일: processor.py 프로젝트: vltr/protoweb
 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))
예제 #2
0
    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')
            ]
        )