使用Python SimpleHTTPServer 快速启动http服务

使用Python SimpleHTTPServer 快速启动http服务

当前Python版本为2.7,3.5以后的版本略有区别,可用$ python --version 查看Python版本

1、进入需要分享的目录

cd  ~

2、开启http服务

# 当前运行 不填写端口 默认8000
python -m SimpleHTTPServer 8888

# 当前终端后台运行
python -m SimpleHTTPServer 8888 &

# 完全后台运行
nohup python -m SimpleHTTPServer 8888 &

后台日志
前端显示

注意事项

  • SimpleHTTPServer有一个特性,如果待共享的目录下有index.html,那么index.html文件会被视为默认主页;如果不存在index.html文件,那么就会显示整个目录列表。
  • 在哪个目录下启动,就会以当前目录为根目录展示列表
原文地址:https://www.cnblogs.com/jakaBlog/p/11394188.html