我正在尝试从Web表单捕获数据,但是python脚本使我出现以下错误:
Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500
localhost
Apache/2.4.35 (Win32) OpenSSL/1.0.2p PHP/7.1.23
Apache error.log:
Bad file descriptor: [client ::1:49399] AH01222: don't know how to spawn child process: C:/xampp/htdocs/website/web.py, referer: http://localhost:8080/website/career.html
python脚本和html代码都位于htdocs中的同一目录中。
web.py:
#! C:/Python27/python
print 'Content-type: text/html\n\n'
import cgi,cgitb
cgitb.enable()
# print 'Content-type: text/html\n\n'
form = cgi.FieldStorage()
role = form.getvalue('jobrole')
role1 = form.getvalue('username')
role=role + " " + role1
fp=open("form.txt","a")
role=role + " " + role1
fp.write(role)
fp.close()
fp=open("form.txt","w")
fp.write(role)
fp.close()
print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>"
print "<title>CGI Program</title>"
print "</head>"
print "<body>"
print "<h2>Hello %s</h2>" % (role)
print "</body>"
print "</html>"
请帮助。