【问题标题】:windows python http.server can not be reachedwindows python http.server 无法访问
【发布时间】:2019-06-08 17:52:08
【问题描述】:

我习惯于从 GNU/Linux 系统运行 python3 -m http.server 以在本地提供文件。

我必须在 Windows 上执行此操作,尽管 python 回复:

Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

我无法访问服务器。

浏览器给出这个:

| address                 | Firefox response | Chrome response         |
| ----------------------  | ---------------  | --------------          |
| http://localhost:8000/  | nothing          | ERR_EMPTY_RESPONSE      |
| http://0.0.0.0:8000/    | nothing          | ERR_ADDRESS_INVALID     |
| http://127.0.0.1/       | nothing          | ERR_CONNECTION_REFUSED  |

我尝试停用防火墙并添加允许 TCP 连接到此端口(不是 80,如上所示)的规则,但没有成功。我不是 Windows 用户,所以我可能错过了一些明显的东西......

其他问题(12)似乎说这很容易。

【问题讨论】:

    标签: python windows localhost


    【解决方案1】:

    碰巧是本地主机绑定问题。

    python -m http.server --bind localhost
    

    解决了。 Python 的响应是:

    Serving HTTP on 127.0.0.1 port 8000 (http://127.0.0.1:8000/) ...
    

    希望它可以帮助别人!

    【讨论】:

      猜你喜欢
      • 2016-08-22
      • 1970-01-01
      • 2019-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-17
      • 2016-10-20
      相关资源
      最近更新 更多