【发布时间】:2016-07-13 11:52:10
【问题描述】:
我想知道我是否有 index.html 并且在 windows CMD 中运行 python -m http.server 80 而在带有 index.html 的目录中它会在我的 IP 上启动一个服务器(假设我打开了 80 端口)然后人们可以连接到我的 IP 看看 index.html 里有什么?
【问题讨论】:
我想知道我是否有 index.html 并且在 windows CMD 中运行 python -m http.server 80 而在带有 index.html 的目录中它会在我的 IP 上启动一个服务器(假设我打开了 80 端口)然后人们可以连接到我的 IP 看看 index.html 里有什么?
【问题讨论】:
人们应该能够毫无问题地连接到您的公共 IP。如果您只想从 localhost 授予访问权限,这会有点复杂:
Is it possible to run python SimpleHTTPServer on localhost only?
【讨论】:
如果
然后它将可以公开访问。要使其仅在本地主机上可用,您应该在 127.0.0.1 上托管
httpd = ServerClass(("127.0.0.1", 80), HandlerClass)
编辑:另一个答案发布了这个很好的链接,直到发布后才看到:Is it possible to run python SimpleHTTPServer on localhost only?
【讨论】:
Serving HTTP on 0.0.0.0 port 80 ...不是错误吗?