python -m SimpleHTTPServer - Listening on 0.0.0.0:

2019-03-14 17:23发布

After cding to my folder I enter

python -m SimpleHTTPServer

and get

Serving HTTP on 0.0.0.0 port 8000 ...

in reply. But when I hit http://0.0.0.0:8000/test.html I get a page not found error.

I've also tried

pushd /path/you/want/to/serve; python -m SimpleHTTPServer; popd

taken from this question

When I hit ls I can see the file and the directory. Anyone know what I'm doing wrong?

8条回答
贼婆χ
2楼-- · 2019-03-14 18:18

Try browsing to http://localhost:8000/test.html or http://127.0.0.1:8000/test.html (those two should be exactly the same thing as long as your hosts file isn't all crazy-like).

0.0.0.0 is usually used by Windows as the "Not connected" IP, and can also be used as a sort of wildcard for when dealing with IPs. I am a bit confused at why your HTTP server is trying to host on 0.0.0.0, though. You may need to edit some config files and set that to 'localhost' or '127.0.0.1'.

查看更多
别忘想泡老子
3楼-- · 2019-03-14 18:19

Run ifconfig on Linux or ipconfig on Windows to find the ip address of the server.

$ sudo ifconfig
wlan0     Link encap:Ethernet  HWaddr 30:3a:64:b3:be:6a  
          inet addr:192.168.1.103  Bcast:192.168.1.255  Mask:255.255.255.0

Here in case the url would be:

http://192.168.1.103:8000/test.html

查看更多
登录 后发表回答