我试着用他们网站上的例子来测试cherrypy框架:
import cherrypy
class HelloWorld(object):
def index(self):
return "Hello World!"
index.exposed = True
cherrypy.quickstart(HelloWorld())
当我运行它时,我在控制台中得到这个响应:
[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
当在本地运行浏览器并指向localhost:8080时,它可以工作,但是当使用server ip:8080时,它不能工作。我需要在某个地方设置服务器的ip地址吗?
默认情况下
cherrypy.quickstart
只绑定到本地主机127.0.0.1
,本地主机可以从服务计算机访问,但不能从通过网络连接到它的计算机访问。如果希望能够从另一台计算机访问站点,则需要设置配置,如here中所述。
下面是一个基本的例子,只是将cherrypy更改为绑定到所有网络接口。
相关问题 更多 >
编程相关推荐