【问题标题】:Premature end of script headers: in basic python script脚本头过早结束:在基本 python 脚本中
【发布时间】:2013-01-16 00:43:42
【问题描述】:

大家好,我正在尝试关注 http://elvenware.com/charlie/development/web/Python/Xampp.html 来使用 xampp 设置 python。我正在运行 xammp usb lite 1.77

按照此处和Python & XAMPP on Windows: how to? 上的指示,

我已经创建了

#!F:/Python27/python

print "Content-type: text/html\n\n"
print "<html><head><title>Hello World from Python</title></head><body>Hello World from a Python CGI Script</body></html>

当我将它放在 cgi-bin 文件夹中并像 htp://localhost/cgi-bin/test.py 一样运行它后尝试运行它时,我得到:

Premature end of script headers: test.py

顺便说一句,包含的 htp://localhost/cgi-bin/cgi.cgi 脚本有效!!

知道我能做些什么来解决这个问题吗?

提前谢谢你,

比尔

【问题讨论】:

  • +1 到@sotapme。你应该把它写下来作为答案。请注意,如果您在命令行上运行相同的脚本,它将引发SyntaxError: EOL while scanning string literal,甚至不会执行第一个print 语句。这意味着没有标头被打印出来,这意味着您将从xampp 收到此错误。

标签: python apache xampp


【解决方案1】:

第 2 行没有结尾 " - 除非是复制/粘贴错误

【讨论】:

  • 你修好了。抱歉,我是 python 新手 - 比尔
【解决方案2】:

我在使用 xampp 时遇到了同样的问题。

问题出在httpd.conf。使用 xampp apache 将与另一个 httpd.conf 一起安装,就像 apache 的独立安装一样。

检查httpd.conf 中的设置并进行更改。

【讨论】:

  • 这将有助于提供多个httpd.conf 文件的完整路径以及您认为有问题的文件中的错误设置。
猜你喜欢
  • 1970-01-01
  • 2014-06-03
  • 2012-09-23
  • 1970-01-01
  • 1970-01-01
  • 2012-12-03
  • 2015-02-04
  • 2011-11-01
  • 2012-06-25
相关资源
最近更新 更多