0
我使用的是使用Vmware的Ubuntu 12.04
並且在Python cgi-bin
上工作。我正在學習本教程:http://archive09.linux.com/feature/136602。我example1.py "Hello, Linux.com!"
成功打印,但example2.py是不是和服務器不斷地說:Python 2.7.8在標題之前輸出腳本結尾:te.py
Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
End of script output before headers: te.py
If you think this is a server error, please contact the webmaster.
Error 500
localhost
Apache/2.4.16 (Unix) OpenSSL/1.0.1p PHP/5.6.12 mod_perl/2.0.8-dev Perl/v5.16.3
而且代碼:
#!/usr/bin/python
import cgi
print "Content-type: text/html"
print
form = cgi.FieldStorage()
laptops = form.getvalue('laptops','0')
desktops = form.getvalue('desktops','0')
print """
<html>
<body>
<form action='second.py'>
How many laptops do you own?
<input type='radio' checked name='laptops' value='0' />0
<input type='radio' name='laptops' value='1' />1
<input type='radio' name='laptops' value='2' />2
<p>
How many desktops do you own?
<input type='radio' checked name='desktops' value='0' />0
<input type='radio' name='desktops' value='1' />1
<input type='radio' name='desktops' value='2' />2
<p>
<input type='submit' />
<p>
You own %d computers.
</form>
</body>
</html>""" % (int(laptops)+int(desktops))
我自己失敗,並不能找出原因。請幫忙
chmod + x ?????? – user3440716
befor執行我做搭配chmod + X example2.py – user3440716
是嘗試給搭配chmod -R 777 example2.py和檢查 –