Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 def index(self):
     return template.render('index.html')
Ejemplo n.º 5
0
 def index(self):
     return template.render("hello.html", word="world!")
Ejemplo n.º 6
0
 def index(self):
     return template.render('hello_filters.html', name='Simple+Easy&Nice')
Ejemplo n.º 7
0
 def index(self, name=None):
     upper_name = name.upper()
     return template.render('get_params.html', show_name=upper_name)