Python (CherryPy) web app deployed locally, but not visible over intranet

走远了吗. 提交于 2019-12-05 09:40:31

问题


I've created a Python web app using CherryPy, and have deployed in on my local machine.

When I try to view it from another computer in the house, nothing comes back.

However, if I create a simple html file, and deploy it with:

$ python -m SimpleHTTPServer

It is visible over the intranet.

I'm stumped as to why my app could work locally, but not be avalable over the intranet, given that there is not a connection problem between these machines, and that I can serve other content on the same port.

I have not used a configuration file, I'm using the default CherryPy settings.


回答1:


The default settings likely bind to localhost, which is not publicly available. If you want CherryPy to run on a public interface, you'll have to direct it to do that. From this discussion I found:

cherrypy.config.update(
    {'server.socket_host': '10.149.4.240' } ) # Pub IP
cherrypy.quickstart()

or

cherrypy.config.update(
    {'server.socket_host': '0.0.0.0'} )      
cherrypy.quickstart()

To bind to all interfaces.



来源:https://stackoverflow.com/questions/7494171/python-cherrypy-web-app-deployed-locally-but-not-visible-over-intranet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!