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 @   rustling  阅读(82)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示