小智 2
python -m SimpleHTTPServer 8000
将在端口 8000(默认端口;低于 1024 的端口将要求您以 root(例如)权限运行)上将当前目录作为网页提供服务sudo
。如果从该端口获取,将返回“200 OK”:
$ python -m SimpleHTTPServer 8000 &
[1] 19976
$ Serving HTTP on 0.0.0.0 port 8000 ...
$ wget localhost:8000
--2014-03-12 00:42:30-- http://localhost:8000/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8000... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:8000... connected.
HTTP request sent, awaiting response... 127.0.0.1 - - [12/Mar/2014 00:42:30] "GET / HTTP/1.1" 200 -
200 OK
Length: 178 [text/html]
Saving to: `index.html'
100%[======================================>] 178 --.-K/s in 0s
2014-03-12 00:42:30 (16.0 MB/s) - `index.html' saved [178/178]
$ cat index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>
<title>Directory listing for /</title>
<body>
<h2>Directory listing for /</h2>
<hr>
<ul>
</ul>
<hr>
</body>
</html>
$
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2650 次 |
最近记录: |