How can I change the default "not found" page?

Asked by Eleanor Berger

Is there a way to customize the default not found (404) page?

Question information

Language:
English Edit question
Status:
Solved
For:
web.py Edit question
Assignee:
No assignee Edit question
Solved by:
Eleanor Berger
Solved:
Last query:
Last reply:
Revision history for this message
Best Eleanor Berger (intellectronica) said :
#1

You can write your own custom notfound handler and assign it to web.webapi.notfound

    def my_notfound():
        print "MY OWN NOT FOUND"
    web.webapi.notfound = my_notfound

Revision history for this message
William Lynch (wlynch) said :
#2

That returns a 200 instead of a 404.

Revision history for this message
William Lynch (wlynch) said :
#3

def my_notfound():
   web.ctx.status = '404 Not Found'
   print "my own not found"
web.webapi.notfound = my_notfound

Although I don't know how long this will be valid. I ripped it from python-webpy/web/webapi.py and the notfound() method.