python快速启用http服务

有时需要将电脑上的文件传输到同WiFi下的手机上,可以使用python启动HTTP服务来快速访问

# python2
python -m SimpleHTTPServer

# python3 默认端口 8000
python -m http.server

# 指定IP和端口
python3 -m http.server -b 192.168.199.198 8080

接下来就可以访问 http://localhost:8000/http://your_ip_address:8000 来查看下载当前目录下的文件。

案例: 部署http服务监测linux设备状态

纯 shell 实现简易的 linux 设备状态监测 https://github.com/badafans/shell-serverstatus

git clone https://github.com/badafans/shell-serverstatus.git
cd shell-serverstatus
# 后台启动脚本
sh status.sh >/dev/null 2>&1 &
# 启用http服务
python3 -m http.server -b 192.168.199.198 8080
# 访问 http://192.168.199.198:8000/ 即可查看
posted @ 2023-01-01 23:54  rustling  阅读(65)  评论(0编辑  收藏  举报