[ACCEPTED]-How do I configure the ip address with CherryPy?-cherrypy
Accepted answer
server.socket_host: '0.0.0.0'
...would also work. That's IPv4 INADDR_ANY, which 2 means, "listen on all interfaces".
In a config 1 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 7 cherrypy init.
If using cherrypy 3.1 syntax, that 6 wold do it:
cherrypy.server.socket_host = 'www.machinename.com'
cherrypy.engine.start()
cherrypy.engine.block()
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.
import cherrypy
class HelloWorld(object):
def index(self):
return "Hello World!"
index.exposed = True
cherrypy.server.socket_host = '0.0.0.0' # put it here
cherrypy.quickstart(HelloWorld())
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.