server.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:django-gateone 作者: jimmy201602 项目源码 文件源码
def render_string(self, template_name, **kwargs):
        #template_path = self.get_template_path()
        #if not template_path:
            #frame = sys._getframe(0)
            #web_file = frame.f_code.co_filename
            #while frame.f_code.co_filename == web_file:
                #frame = frame.f_back
            #template_path = os.path.dirname(frame.f_code.co_filename)
        #with RequestHandler._template_loader_lock:
            #if template_path not in RequestHandler._template_loaders:
                #loader = self.create_template_loader(template_path)
                #RequestHandler._template_loaders[template_path] = loader
            #else:
                #loader = RequestHandler._template_loaders[template_path]
        #t = loader.load(template_name)
        #namespace = self.get_template_namespace()
        #namespace.update(kwargs)
        #return t.generate(**namespace)
        with io.open(template_name, mode='r',encoding='UTF-8') as f:
            html = f.read()
        template_strings = Template(html)
        return template_strings.render(context=Context(dict_=kwargs))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号