Search code examples
pythonroutescherrypydispatcher

cherrypy handle all request with one function or class


i'd like to use cherrypy but i don't want to use the normal dispatcher, i'd like to have a function that catch all the requests and then perform my code. I think that i have to implement my own dispatcher but i can't find any valid example. Can you help me by posting some code or link ?

Thanks


Solution

  • make a default function:

    import cherrypy
    
    class server(object):
            @cherrypy.expose
            def default(self,*args,**kwargs):
                    return "It works!"
    
    cherrypy.quickstart(server())