Your browser does not support JavaScript!
Upvotes Anonymous 5 User 0

How to Create a Custom 404 Page with CherryPy

This page discusses custom error handling in CherryPy. Here's an example for providing the user with a custom 404 page (based on the 402 example from that page):
from controllers.home import HomeController
import cherrypy

def error_page_404(status, message, traceback, version):
    return "404 Error!"

def start_server():
    server_config = {
        'server.socket_host': '',
        'server.socket_port': 60000

    cherrypy.tree.mount(HomeController(), '/Home', {})
    cherrypy.config.update({'error_page.404': error_page_404})

if __name__ == '__main__':
Was this helpful?


Leave a Comment

I agree to the Terms of Service
Design © 2015, Downranked, LLC.,
Original user code contributions under MIT License