2013-01-12 24 views
1

我想在我的sourceforge資源庫中託管一個示例程序test.py。我從目錄/home/project-web/motiur/cgi-bin/上傳了我的文件,然後去了motiur.sourceforge.net/cgi-bin/test.py。不幸的是,我得到了一個錯誤,表明標題提前結束。在sourceforge中設置python

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) 

順便說一句,我使用FileZilla的窗口和已設置文件權限爲755,即每個人都可以執行該文件。這是一個noob問題,一點幫助將不勝感激。謝謝。

+0

什麼是確切的錯誤? – yannis

+0

@YannisRizos:錯誤在於;訪問此頁面時遇到錯誤。 1.服務器:motiur.sourceforge.net 2. URL路徑:/cgi-bin/test.py 3.錯誤筆記:腳本頭過早結束:test.py 4.錯誤類型:500 5。請求方法:GET 6.請求查詢字符串: 7.時間:2013-01-12 14:49:39 UTC(1358002179) – motiur

+0

@YannisRizos:任何建議..? – motiur

回答

0

試試這個:

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

您可能需要兩個 '\ n \ n' 響應的身體前。

編輯

那就試試這個:

#!/usr/bin/env python 

在頂部,而不是

#!/usr/local/bin/python 
+0

抱歉,錯誤仍然存​​在。這行代碼是否有問題:'#!/ usr/local/bin/python import cgi,cgitb'。順便說一下,我的代碼在我的localhost中運行得很好。我懷疑python解釋器和我的test.py文件的訪問鏈接的鏈接。 – motiur

+0

檢查我的更新大約10秒 –

+0

對不起,我仍然'腳本頭'提前結束錯誤。您可以訪問http://motiur.sourceforge.net/cgi-bin/test.py網站查看錯誤。 – motiur