我正在尝试在我的sourceforge存储库中托管一个示例程序test.py。我从/home/project-web/motiur/cgi-bin/目录上传了我的文件,然后转到了motiur.sourceforge.net/cgi-bin/test.py。不幸的是,我得到了一个提示报头过早结束的错误。
test.py的源码:
#!/usr/local/bin/python
import cgi, cgitb
print "Content-type:text/html\n"
print "<html><body>This is another test</body></html>"确切的错误是:
An error has been encountered in accessing this page.
1. Server: motiur.sourceforge.net
2. URL path: /cgi-bin/test.py
3. Error notes: Premature end of script headers: test.py
4. Error type: 500
5. Request method: GET
6. Request query string:
7. Time: 2013-01-12 14:49:39 UTC (1358002179)顺便说一句,我在windows中使用的是filezilla,并且已经将文件权限设置为755,即每个人都可以执行该文件。这是一个新手问题,如果能帮上一点忙,我们将不胜感激。谢谢。
发布于 2013-01-13 00:48:51
试试这个:
print 'Content-type: text/html'
print ''
print '<html><body>This is another test</body></html>'您可能需要在响应正文之前添加两个'\n\n‘。
编辑
然后试试这个:
#!/usr/bin/env python在顶部,而不是
#!/usr/local/bin/pythonhttps://stackoverflow.com/questions/14294492
复制相似问题