Issue #876 resolved

Ability to have different custom 404 page for seperate 404 URLs.

Anonymous created an issue

To facilitate wiki like features of being able to go to a URL that is not found and to be returned a page that is unique to that URL so that you can then create a new page.

A solution is covered here:

Reported by

Comments (2)

  1. Anonymous

    I found that in 3.1 you can do:

    class MyErrorPage():
        def __init__(self, body):
            self.body = body
        def __call__(self, **kwargs):
            return self.body
    def foo_bar_not_found():
         error = """<html><head></head><body>404 Not Found</body></html>"""
         cherrypy.request.error_page[404] = MyErrorPage(body=error)
         raise HTTPError(404)

    Is there a better way?

  2. Log in to comment