python实现简易http服务器

拉起服务

在http server访问的根路径下执行以下命令即可拉起简易的http服务器,用以共享文件等诉求。
python2使用SimpleHTTPServer
python -m SimpleHTTPServer

python3使用http.server
python3 -m http.server

指定端口号

默认开启的端口号是8000,可以指定端口号。
python3 -m http.server 1234

后台运行

借助nohup命令可以实现后台运行服务。
nohup python3 -m http.server &

posted @ 2021-07-05 11:50  hunter-w  阅读(383)  评论(0编辑  收藏  举报