[英]Python SimpleHTTPServer serving wrong index.html?
I have a simple script for viewing the webpage I am working on. 我有一个简单的脚本来查看正在处理的网页。
import SimpleHTTPServer
import SocketServer
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
I've copied this script to a few directories with different index.html pages I am working on. 我已将此脚本复制到我正在处理的具有不同index.html页面的几个目录中。 I killed the server serving index_A (in its own directory, Development/A).
我杀死了服务index_A的服务器(在其自己的目录Development / A中)。 However when I try to run the script in Development/B (which should serve index_B) it is still serving index_A.
但是,当我尝试在Development / B中运行脚本(应该为index_B服务)时,它仍在为index_A服务。
Edit: When I change the port I am using, it serves the correct index. 编辑:当我更改正在使用的端口时,它将提供正确的索引。 Still not sure why the old index shows up in the old port, even when I kill the process.
仍然不确定为什么旧索引会出现在旧端口中,即使我终止了该进程也是如此。
I just had this same problem and it was very distressing and stubborn. 我只是遇到了同样的问题,这非常令人困扰和固执。 Tried all the suggestions here and also here with commands
freeport
, netstat
, ps
, lsof
and kill
. 在此处以及此处使用命令
freeport
, netstat
, ps
, lsof
和kill
尝试了所有建议。 Few hours later found that it was something more elementary. 几个小时后发现它更基本。 Even after several restarts the same
index.html
was still being served at 0.0.0.0:8000
. 即使在几次重启后,仍以
0.0.0.0:8000
相同的index.html
。 But tried the other browsers and it was only happening in Chrome! 但是尝试了其他浏览器,而且这种情况仅在Chrome中发生! so cleared the cache and it went away.
因此清除了缓存,它就消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.