如何使用CherryPy配置IP地址? [英] How do I configure the ip address with CherryPy?

查看:77
本文介绍了如何使用CherryPy配置IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用python和CherryPy创建一个大约2人使用的简单内部网站.我将内置的Web服务器与CherryPy.quickstart一起使用,并且从未弄乱过配置文件.我最近更换了机器,所以我安装了最新的Python和cherrypy,当我运行该站点时,可以从localhost:8080访问它,但不能通过IP或Windows机器名访问它.可能是机器配置不同,也可能是CherryPy或Python的较新版本.有什么想法可以绑定到正确的IP地址吗?

I'm using python and CherryPy to create a simple internal website that about 2 people use. I use the built in webserver with CherryPy.quickstart and never messed with the config files. I recently changed machines so I installed the latest Python and cherrypy and when I run the site I can access it from localhost:8080 but not through the IP or the windows machine name. It could be a machine configuration difference or a newer version of CherryPy or Python. Any ideas how I can bind to the correct IP address?

为了清楚起见,我目前根本没有配置文件.

to make it clear, I currently don't have a config file at all.

推荐答案

这取决于您如何运行cherrypy init.

That depends on how you are running the cherrypy init.

如果使用cherrypy 3.1语法,那就去做吧:

If using cherrypy 3.1 syntax, that wold do it:

cherrypy.server.socket_host = 'www.machinename.com'
cherrypy.engine.start()
cherrypy.engine.block()

当然,您可以拥有更多花哨的东西,例如对服务器类进行子类化或使用配置文件.文档中介绍了这些用途.

Of course you can have something more fancy, like subclassing the server class, or using config files. Those uses are covered in the documentation.

但这应该足够了.如果不只是告诉我们您在做什么和令人毛骨悚然的版本,我将编辑此答案.

But that should be enough. If not just tell us what you are doing and cherrypy version, and I will edit this answer.

这篇关于如何使用CherryPy配置IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆