本文介绍了更改目录Python SimpleHTTPServer使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行基本的Python SimpleHTTPServer以在浏览器中检出某些文件.一旦SimpleHTTPServer在一个目录中运行,如何停止它并使用另一个目录?或者只是将其切换到新版本.

Running a basic Python SimpleHTTPServer to check out some files in browser. Once the SimpleHTTPServer is running in one directory how do you stop it and use a different directory? or just have it switch to the new one.

当前在终端中使用:

python -m SimpleHTTPServer 8008

然后,如果我尝试在另一个目录上运行,则表明该目录已被使用.那么基本上如何停止给定的SimpleHTTPServer实例?

Then if I try to run on another directory it says it's already in use. So basically how to I stop a given instance of SimpleHTTPServer?

推荐答案

您只能使用SimpleHTTPServer绑定到每个端口一次.如果您已经在端口8008上运行服务器,则无法在该端口上运行另一个侦听实例.

You can only bind to each port once with SimpleHTTPServer. If you are already running the server on port 8008, you can not run another instance listening on that same port.

您应该停止服务器,然后从另一个目录启动它...或选择其他端口号来运行第二个实例.

you should stop the server, and launch it from the other directory... or choose a different port number for running the 2nd instance.

这篇关于更改目录Python SimpleHTTPServer使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 18:36