Featured image of post Python小技巧 - Python内置 HTTP server

Python小技巧 - Python内置 HTTP server

Python有个非常好用的功能,Python内置 HTTP server,对于预览网站非常有用,尤其是静态网站开发的时候

Python 3 以上版本使用方法如下

1
2

$ python3 -m http.server

类型如下的输出代表运行正常

1
2

Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

Python 2 版本使用方法如下

1
2

$ python -m SimpleHTTPServer 8000

类型如下的输出代表运行正常

1
2

Serving HTTP on 0.0.0.0 port 8000 ...

访问以上地址,打开的就是当前目录下的文件

Licensed under CC BY-NC-SA 4.0
最后更新于 Jul 30, 2025 10:41 +0800