到目前为止,我没有让Cherrypy与Chrome合作,但我想。 所以这是代码:
import cherrypy
class HelloWorld(object):
def index(self):
return "Hello World!"
index.exposed = True
cherrypy.quickstart(HelloWorld())
当我使用Python 2.6在我的Mac OS X 10.7.3上运行它时,我输入:
http://127.0.0.1:8080
适用于:Firefox,Opera,Safari
Chrome:无效=> “糟糕,无法连接......”
任何人都可以重现这个吗?我的错误在哪里?
编辑:这是从开始的输出
[15/Apr/2012:14:09:17] ENGINE Listening for SIGHUP.
[15/Apr/2012:14:09:17] ENGINE Listening for SIGTERM.
[15/Apr/2012:14:09:17] ENGINE Listening for SIGUSR1.
[15/Apr/2012:14:09:17] ENGINE Bus STARTING
CherryPy Checker:
The Application mounted at '' has an empty config.
[15/Apr/2012:14:09:17] ENGINE Started monitor thread 'Autoreloader'.
[15/Apr/2012:14:09:17] ENGINE Started monitor thread '_TimeoutMonitor'.
[15/Apr/2012:14:09:17] ENGINE Serving on 127.0.0.1:8080
[15/Apr/2012:14:09:17] ENGINE Bus STARTED
答案 0 :(得分:1)
您需要将主机设置为0.0.0.0。例如 cherrypy.config.update({' server.socket_host':' 0.0.0.0',' server.socket_port':8000})