0

到目前为止,我还没有让 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
4

1 回答 1

1

您需要将主机设置为 0.0.0.0。例如cherrypy.config.update({'server.socket_host':'0.0.0.0', 'server.socket_port':8000})

于 2016-03-08T04:26:02.743 回答