Example #1
0
    def not_found(self, req):

        """
        Use this when you KNOW you should reply with a 404.

        Otherwise, just return None out of the route method and let the
        NotFound handler catch the request.

        """

        #Determine what we return based on request type
        if req.is_AJAX:
            resp = Response.plain("404 NOT FOUND")

        if req.is_JSON:
            resp = Response.json(dict(
                reply_timestamp=datetime.datetime.now(),
                message="404 NOT FOUND '{0}'".format(req.line_one),
                success=False))

        else:
            resp = Response.tmpl(self.four_zero_four_template)

        resp.status = '404 NOT FOUND'

        return resp
Example #2
0
    def not_found(self, req):

        """
        Use this when you KNOW you should reply with a 404.

        Otherwise, just return None out of the route method and let the
        NotFound handler catch the request.

        """

        #Determine what we return based on request type
        if req.is_AJAX:
            resp = Response.plain("404 NOT FOUND")

        else:
            resp = Response.tmpl(self.four_zero_four_template)

        resp.status = '404 NOT FOUND'

        return resp