问题标签 [simplehttpserver]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
4355 浏览

python - Python SimpleHTTPServer:更改响应标头

我使用 python 的 SimpleHTTPServer 来测试应用程序。

现在进行测试,我需要更改服务器响应标头字段“Server”。现在我有“服务器:SimpleHTTP/0.6 Python/2.7.3”我想要类似“服务器:Apache123”的东西。

是否可以更改此字段?谢谢。

0 投票
1 回答
944 浏览

python - Python:SimpleHTTPServer 内容长度错误

我正在尝试使用 Python 中的内置功能在SimpleHTTPServer本地提供静态页面。我从python -m SimpleHTTPServer.

目前,HTML 只是

服务器返回状态为 200 的页面,但浏览器控制台说ERR_CONTENT_LENGTH_MISMATCH并且不会呈现任何内容。如果我将内容更改为单行文本,它会显示得很好。添加另一行会再次中断它。根据评论,问题似乎出在换行符上。我正在用 Sublime Text(在 Windows 上)写这篇文章,并使用 Chrome 来查看,如果有帮助的话。

0 投票
1 回答
6460 浏览

python - Python SimpleHTTPServer 404 页面

我最近一直在使用 Python 的 SimpleHTTPServer 在我的网络上托管文件。我想要一个自定义的 404 页面,所以我对此进行了研究并得到了一些答案,但我仍然想使用我拥有的这个脚本。那么,我必须添加什么才能在此脚本中获得 404 页面?

0 投票
2 回答
981 浏览

python - Local server giving wrong files. Is it possible I'm running 2 python servers?

I'm in the directory /backbone/ which has a main.js file within scripts. I run python -m SimpleHTTPServer from the backbone directory and display it in the browser and the console reads the error $ is not defined and references a completely different main.js file from something I was working on days ago with a local python server.

I am new to this and don't have an idea what's going on. Would love some suggestions if you have time.

0 投票
2 回答
1563 浏览

javascript - d3 does not support cross-domain request even though after using SimpleHTTPServer

I want to load a tsv file from a specific directory which is different from the d3 directory. My d3 script resides under /home/meet/workspace/d3_test/scripts and SimpleHTTPServer running at "/" root.

Throwing an error:

Note:-

  1. Tried passing file:/// which is not supported
  2. Mike mentions link with SimpleHTTPServer
  3. Also, I don't want to edit my browser settings
0 投票
0 回答
507 浏览

python - 使用python从目录提供文件

我正在使用 simplehttpserver 从目录中提供文件。

我可以访问它,但如果我这样做

我看到的是源代码,而不是代码的输出。

我究竟做错了什么?

0 投票
1 回答
792 浏览

python - 使用 Python 简单的 http 服务器时字体真棒不加载

我有这个简单的 html 文件,它使用很棒的字体显示大拇指向下图标。

在这里工作小提琴

现在,当我尝试使用 Python SimpleHTTPServer 在我的本地机器上冲洗它时,我的字体没有正确呈现。我得到这个输出

font_awesome_python

但是当我使用 php 服务器托管相同的内容时,我得到了正确的结果,如小提琴所示。

知道这是否是 python 简单 HTTP 服务器的限制吗?

0 投票
2 回答
247 浏览

python - Python 服务器在 GET 上返回文件的问题

我创建了一个简单的线程 python 服务器,我有两个格式参数,一个是 JSON(返回字符串数据),另一个是 zip。当用户选择 format=zip 作为输入参数之一时,我需要服务器将 zip 文件返回给用户。我应该如何在我的服务器的 do_GET() 上将文件返回给用户?我是只返回可以下载文件的 URL,还是可以直接将文件发回给用户?如果选项二是可能的,我该怎么做?

谢谢

0 投票
1 回答
819 浏览

python - Python SimpleHttpServer 后台错误?

使用一个非常简单的 BaseHttpServer(下面的代码)我遇到了以下问题:

使用后台启动服务器./testserver.py &工作正常,服务器响应端口 12121 。当我输入disown服务器仍然响应。关闭终端后,服务器在下一个请求后停止,输入/输出错误test.log

重构步骤:

关闭终端,向服务器发送请求-> 服务器没有响应。

我发现的唯一解决方案是重定向stdoutand stderr: $ ./testserver > /dev/null 2>&1 或 @Daniel 声明以通常的方式调用它nohup

以前有没有人遇到过这个错误,或者如果没有输出可能,为什么这是 HttpServer 崩溃的理想行为?


测试服务器.py

0 投票
2 回答
6180 浏览

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

有人可以解释为什么我会收到以下错误吗?

从以下目录中,我正在运行“python -m SimpleHTTPServer”

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

是的,在 js 目录中,我有两个文件“bootstrap.js”和“bootstrap.min.js”

我的 index.html 文件如下所示: