1

I am running a python SimpleHTTPServer and serving a html file. That html file includes couple of javascript files. When the html file is served by the server I get the following errors.

1.0.0.127.in-addr.arpa - - [15/Jun/2012 13:42:54] code 404, message File not found
1.0.0.127.in-addr.arpa - - [15/Jun/2012 13:42:54] "GET /lib/jquery-ui/jquery-ui.min.js 

Html file contents (only relevant lines shown):

<script type="text/javascript" src="../../lib/jquery-ui/jquery-ui.min.js"></script>

Python command used to run the server. It is run in the directory where index.html is present

python -m SimpleHTTPServer 8000

I have the files jquery-ui-min.js in my local filesystem. But the search somehow is stripping the ../.. and searching in /lib/jquery-ui/jquery-ui.min.js

4

1 回答 1

0

如果你从一个目录运行 SimpleHTTPServer,它不会超过你运行它的根目录。这是一项安全功能。

例如,假设以下布局:

/foo/bar/baz/index.html
/foo/lib/jquery-ui/jquery-ui.min.js

如果您从 运行 SimpleHTTPServer /foo/bar/baz,您将无法访问上面的任何文件/foo/bar/baz。您可以改为从中运行服务器/foo/,它会工作。您还可以在 baz 目录中将符号链接添加到要包含的 JavaScript。

于 2012-06-15T21:26:24.240 回答