Exemplo n.º 1
0
 def get(self):
     pkgs = [Package(pkg) for pkg in pkgutil.iter_modules()]
     self.response.headers['Content-Type'] = 'text/html'
     payload = JINJA_ENVIRONMENT.get_template('pkgs.html').render({
         'pkgs': pkgs
     })
     self.response.write(payload)
Exemplo n.º 2
0
    def get(self):
        user = users.get_current_user()

        if user:
            self.response.headers['Content-Type'] = 'text/html'
            payload = JINJA_ENVIRONMENT.get_template('chat.html').render({
                'room_name': DEFAULT_ROOM_NAME,
                'user_name': user.nickname(),
            })
            self.response.write(payload)

        else:
            self.redirect(users.create_login_url(self.request.uri))
Exemplo n.º 3
0
 def output(self, data, template=None):
     """
     Outputs to a specified template the data given. Called from do_request normally
     """
     if self.to_write:
         if self.using_post:
             self.response.write('FORMDATA:')
             if self.err:
                 for key, val in self.err.items():
                     self.response.write('<div class="alert alert-danger" data-for="%s">%s</div>' %
                                         ('' if key is None else key, val))
             else:
                 self.response.write('<div class="alert alert-success" data-for="">%s</div>' %
                                     self.success_msg)
         else:
             data['user'] = self.user
             template = self.template if template is None else template
             self.response.write(JINJA_ENVIRONMENT.get_template(template).render(**data))