yuenshome / yuenshome.github.io

https://yuenshome.github.io
MIT License
81 stars 15 forks source link

使用Python SimpleHTTPServer 快速启动http服务 #94

Open ysh329 opened 4 years ago

ysh329 commented 4 years ago

使用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 &

后台日志: image

前端显示: image image

注意事项 SimpleHTTPServer有一个特性,如果待共享的目录下有index.html,那么index.html文件会被视为默认主页;如果不存在index.html文件,那么就会显示整个目录列表。 在哪个目录下启动,就会以当前目录为根目录展示列表