Exemple #1
0
    def __call__(self, request, *args, **kws):
        try:
            response = self.service(request, *args, **kws)
            if response is not None:
                if isinstance(response, Response):
                    self.send_response(request, response)
                else:
                    self.send_response(request, Response(str(response)))
        except Exception, exception:
            if request.debug:
                print_stack(file = stderr)
                print>>stderr, '----- page caught here ----'
                print_exc(file = stderr)
                print>>stderr, '503 - %s' % request.full_path

            self.send_response(request, Page(
                code = 503,
                body_content = (
                    tags.h1('Server Error'),
                    str(exception.__class__.__name__),
                    ': ',
                    str(exception)
                )
            ))
            raise
Exemple #2
0
def json_service(kit, json):
    return Page(title="Page", body_content=(tags.h1("Title"), tags.p("Content")))
Exemple #3
0
 def header(self):
     return tags.h1(self.path())
Exemple #4
0
 def body_content(self):
     return (
         tags.h1('Not Found'),
         tags.p(self.path())
     )