def render_static(ext, path): # stupid inefficient, but that's what you get headers = tools.make_ctype(ext, config.default_mtype) try: return open(path).read(), 200, headers except IOError: return render_error(404, "Not Found")
def render_template(self, path, variables, ext=None): ext = ext or os.path.splitext(path)[1] headers = tools.make_ctype(ext, self.default_mtype) if 'headers' in variables: sessions.load_session(variables) context = {'web': variables, 'module': tools.module, 'response_headers': headers } template = self.env.get_template(path) result = template.render(**context) if 'headers' in variables: sessions.save_session(variables, headers) return result, 200, headers
def render_static(self, ext, path): # stupid inefficient, but that's what you get headers = tools.make_ctype(ext, self.default_mtype) return open(path).read(), 200, headers
def render_template(self, ext, path, variables): headers = tools.make_ctype(ext, self.default_mtype) template = self.env.get_template(path) return template.render(**variables), 200, headers