Search code examples
pythoncherrypyrestart

Correct way of implementing Cherrypy's autoreload module


As title, I am following the tutorial of cherrypy at http://docs.cherrypy.org/en/latest/tutorials.html#tutorial-1-a-basic-web-application and I want to see the changes in my script immediately without restarting my cherrypy server.

I read from http://www.packtpub.com/article/overview-cherrypy-a-web-application-server-2 that there is an autoreload module that skip the restarting process but I don't know how to implement it.

Can anyone help?


Solution

  • I found it in http://cherrypy.readthedocs.org/en/latest/deploy.html

    import cherrypy
    
    class Root(object):
        @cherrypy.expose
        def index(self):
            return "Hello World!"
    
    
    cherrypy.config.update({'server.socket_port': 8090,
                            'engine.autoreload_on': False,
                            'log.access_file': './access.log',
                            'log.error_file': './error.log'})
    cherrypy.quickstart(Root())
    

    It works but the cherrypy server script cannot be run from ipython notebook.