gpt4 book ai didi

python - 如何从局域网中的另一台PC 访问Bottle 开发服务器?

转载 作者:太空狗 更新时间:2023-10-29 17:53:15 27 4
gpt4 key购买 nike

我在一台 PC 上运行 bottle.py 教程,我可以使用以下命令访问它

http://localhost:8080/hello/world

但是,当我尝试从局域网上的另一台PC访问它(IP地址是192.168.1.10)时,使用

http://192.168.1.10:8080/hello/world

我收到“无法打开页面”错误。

我在PC上运行了Apache网络服务器,我可以毫无问题地访问网络服务器

http://192.168.1.10

有什么建议吗?谢谢。

最佳答案

假设您正在谈论 Quickstart: “Hello World”示例:

改变这一行:

run(host='localhost', port=8080, debug=True)

绑定(bind)到您计算机的公共(public) IPv4 地址:

run(host='192.168.1.10', port=8080, debug=True)

或者通过这个来监听包括外部接口(interface)在内的所有接口(interface) [来源: bottle.run, Bottle API Reference ]:

run(host='0.0.0.0', port=8080, debug=True)

然后您应该可以从本地 PC 以及 LAN 上的另一台 PC 访问 http://192.168.1.10:8080/hello/world。或者使用完全限定域名 (FQDN)。

如果连接仍然被拒绝,请检查您的防火墙设置。

关于python - 如何从局域网中的另一台PC 访问Bottle 开发服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14958597/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com