有什么方法可以设置你想要启动 SimpleHTTPServer 或 BaseHTTPServer 的目录吗?
最佳答案
如果您直接从命令行使用 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
关于python - 运行 SimpleHTTPServer 时设置当前目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2469256/