1

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 に設定していました。つまり、誰でもファイルを実行できます。これは初心者の質問です。少し助けていただければ幸いです。ありがとう。

4

1 に答える 1

0

これを試して:

print 'Content-type: text/html'
print ''
print '<html><body>This is another test</body></html>'

応答の本文の前に2つの'\n\n'が必要になる場合があります。

編集

次に、これを試してください:

#!/usr/bin/env python

代わりに上部に

#!/usr/local/bin/python
于 2013-01-12T16:48:50.790 に答える