运行SimpleHTTP时设置当前目录

2024-03-28 20:33:48 发布

您现在位置:Python中文网/ 问答频道 /正文


Tags: python
1条回答
网友
1楼 · 发布于 2024-03-28 20:33:48

如果直接从命令行使用SimpleHTTPServer,则可以简单地使用shell功能:

pushd /path/you/want/to/serve; python -m SimpleHTTPServer; popd

在Python 3中,必须使用:

pushd /path/you/want/to/serve; python -m http.server; popd

The SimpleHTTPServer module has been merged into http.server in Python 3.0

相关问题 更多 >