![](/img/trans.png)
[英]python - http.server works on windows but doesnt on debian
[英]windows python http.server can not be reached
我習慣於從 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 用戶,所以我可能錯過了一些明顯的東西......
碰巧是本地主機綁定問題。
python -m http.server --bind localhost
解決了。 Python 的響應是:
Serving HTTP on 127.0.0.1 port 8000 (http://127.0.0.1:8000/) ...
希望它可以幫助別人!
我遇到了同樣的問題,並通過在 Windows 10 中將網絡類型更改為私有來解決它:
現在,當網絡類型為私有時,我可以使用訪問 localhost
http://127.0.0.1:8000/
在 Firefox 和
py -m http.server
在命令提示符中
希望這可以幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.