SimpleHTTPServer 404 消息 文件未找到(尝试加载 bootstrap.js)

1 投票
2 回答
7045 浏览
提问于 2025-04-18 06:47

有人能解释一下我为什么会遇到以下错误吗?

我在这个目录下运行了“python -m SimpleHTTPServer”命令:

[blah@blah:~/Dropbox/bootstrap]: ls
css     img     index.html  js

当我在浏览器里访问 localhost:8000/ 时,出现了以下错误:

127.0.0.1 - - [16/May/2014 10:22:37] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [16/May/2014 10:22:37] code 404, message File not found
127.0.0.1 - - [16/May/2014 10:22:37] "GET /%E2%80%9Djs/bootstrap.js%E2%80%9D HTTP/1.1" 404 -

对了,在 js 目录里,我确实有两个文件“bootstrap.js”和“bootstrap.min.js”。

我的 index.html 文件是这样的:

<!DOCTYPE html>

<html>

    <head>
        <meta charset="utf-8">
        <title>My First Bootstrap Project</title>


    </head>

    <body>
        <div class="container">

            <h1><a href="#">Bootstrap Site</a></h1>
        </div>


        <link rel=”stylesheet” href=”css/bootstrap.css”  type=”text/css”/>
        <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
        <script src=”js/bootstrap.js”></script>
    </body>

</html>

2 个回答

0

我发现我出现404错误的原因是因为8000端口上已经有一个程序在运行;解决办法就是先释放这个端口。

在Mac(Linux)上:

# If something is running on port 8000, this command will return
# the process with the process ID (PID) as the 2nd item
lsof -n -i :8000 | grep LISTEN

# Replace <PID> with whatever PID was returned above
kill -9 <PID>

之后我就可以在这个端口上运行一个新的程序了。

1

我觉得你的问题可能跟你在HTML中使用的弯引号(智能引号)有关。你应该改用普通的引号:

regular: "
curly (smart): ”

撰写回答