How do I configure the ip address with CherryPy? How do I configure the ip address with CherryPy? python python

How do I configure the ip address with CherryPy?


server.socket_host: '0.0.0.0'

...would also work. That's IPv4 INADDR_ANY, which means, "listen on all interfaces".

In a config file, the syntax is:

[global]server.socket_host: '0.0.0.0'

In code:

cherrypy.server.socket_host = '0.0.0.0'


That depends on how you are running the cherrypy init.

If using cherrypy 3.1 syntax, that wold do it:

cherrypy.server.socket_host = 'www.machinename.com'cherrypy.engine.start()cherrypy.engine.block()

Of course you can have something more fancy, like subclassing the server class, or using config files. Those uses are covered in the documentation.

But that should be enough. If not just tell us what you are doing and cherrypy version, and I will edit this answer.


import cherrypyclass HelloWorld(object):    def index(self):        return "Hello World!"    index.exposed = Truecherrypy.server.socket_host = '0.0.0.0' # put it here cherrypy.quickstart(HelloWorld())