[ACCEPTED]-How do I configure the ip address with CherryPy?-cherrypy

Accepted answer
Score: 39
server.socket_host: ''

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

In a config 1 file, the syntax is:

server.socket_host: ''

In code:

cherrypy.server.socket_host = ''
Score: 18

That depends on how you are running the 7 cherrypy init.

If using cherrypy 3.1 syntax, that 6 wold do it:

cherrypy.server.socket_host = 'www.machinename.com'

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

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

Score: 8
import cherrypy

class HelloWorld(object):
    def index(self):
        return "Hello World!"
    index.exposed = True

cherrypy.server.socket_host = '' # put it here 


More Related questions