Problems Starting Cherrypy Hello World Example

I am trying to test the cherry structure using an example from their website:

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

When I run it, I get this response in the console:

 [05/Dec/2011:00:15:11] ENGINE Listening for SIGHUP. [05/Dec/2011:00:15:11] ENGINE Listening for SIGTERM. [05/Dec/2011:00:15:11] ENGINE Listening for SIGUSR1. [05/Dec/2011:00:15:11] ENGINE Bus STARTING CherryPy Checker: The Application mounted at '' has an empty config. [05/Dec/2011:00:15:11] ENGINE Started monitor thread '_TimeoutMonitor'. [05/Dec/2011:00:15:11] ENGINE Started monitor thread 'Autoreloader'. [05/Dec/2011:00:15:12] ENGINE Serving on 127.0.0.1:8080 [05/Dec/2011:00:15:12] ENGINE Bus STARTED 

When the browser starts locally and pointig to localhost: 8080 it works, but in the outside world when using serverip: 8080 it is not. Should I set the server IP address somewhere?

+8
python cherrypy
source share
1 answer

By default, cherrypy.quickstart will only bind to localhost 127.0.0.1 , which can be accessed from the host computer, but not to computers connected to it through the network.
If you want to access the site from another computer, you need to set the configuration as described here .

Here is a basic example, just modifying cherrypy to bind to all network interfaces.

 import cherrypy class HelloWorld(object): def index(self): return "Hello World!" index.exposed = True # bind to all IPv4 interfaces cherrypy.config.update({'server.socket_host': '0.0.0.0'}) cherrypy.quickstart(HelloWorld()) 
+11
source share

All Articles