以共享目录 /home/haoel
IP地址192.168.1.1
为例:
$ cd /home/haoel
$ python -m SimpleHTTPServer 3000
若开启失败:
python -m http.server 3000
只让这个HTTP服务器
服务于本地环境:
import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"
if sys.argv[1:]:
port = int(sys.argv[1])
else:
port = 8000
server_address = ('127.0.0.1', port)
HandlerClass.protocol_version = Protocol
httpd = ServerClass(server_address, HandlerClass)
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()
参考资料:
coolshell.cn/articles/1480.html
版权属于:soarli
本文链接:https://blog.soarli.top/archives/448.html
转载时须注明出处及本声明。