def index(self, **kwargs): # Form input fields are received as keyword arguments if controller.method() == "GET": return template.render('form.html') else: # For the template we provide the input variables extended with the sqrt result kwargs['number_sqrt'] = str(sqrt(float(kwargs['number']))) return template.render('form_submit.html', **kwargs)
def default(self, *args): source_name = 'index' if len(args) == 0 else args[0] if not re.match('^([a-z_])+$', source_name): return filename = join(dirname(__file__), source_name+'.py') if not exists(filename): return with open(filename) as file: code = file.read() source = '<b>controllers/%s</b>' % basename(filename) source += highlight(code, PythonLexer(), HtmlFormatter(noclasses=True)) source += self._dump_views_matching_regex("template.render\('([a-z_]*).", code) controller.set_response('Content-Type', 'text/html') return template.render('view_source.html', source_name=source_name, content=source)
def default(self, *params): template_args = {'current_path': '/'.join(params), 'next_path': str(len(params) + 1)} print '/'.join(params) return template.render('path_elements.html', **template_args)
def index(self): return template.render('index.html')
def index(self): return template.render("hello.html", word="world!")
def index(self): return template.render('hello_filters.html', name='Simple+Easy&Nice')
def index(self, name=None): upper_name = name.upper() return template.render('get_params.html', show_name=upper_name)