问题描述:

Before I start off, I'd like to say I am new to all of this, just starting a degree.

I have this problem with XAMPP, when trying to run a Python file. This was given to us by the University to help set up the server, however I'm scratching my head over what is wrong. When I load it up on the server, it replies back "End of script output before headers: helloWorldoneform.py".

Here is the code:

 #!/Python35/python

# Import modules for CGI handling

import cgi, cgitb

# Create instance of FieldStorage

form = cgi.FieldStorage()

# Get data from fields

name = form.getvalue('name')

module = form.getvalue('module')

print ("Content-Type: text/html") # HTML is following

print ()

print ("<HEAD>")

print ("<TITLE>Hello - Form processing</TITLE>")

print ("</HEAD>")

print ("<BODY>")

print ("<H1>Hello", name, "You're enrolled to study ", module, ". Enjoy!</H1>")

print ("</BODY>")

print ("</HTML>")

This is what the error log says:

[Sun Sep 25 13:41:25.916230 2016] [cgi:error] [pid 8068:tid 1832] [client ::1:63120] End of script output before headers: helloWorldoneform.py, referer: http://localhost/webprog/helloWorldoneform.html

[Sun Sep 25 13:41:25.916230 2016] [cgi:error] [pid 8068:tid 1832] [client ::1:63120] AH01215: Traceback (most recent call last):\r: D:/xampp/htdocs/webprog/helloWorldoneform.py, referer: http://localhost/webprog/helloWorldoneform.html

[Sun Sep 25 13:41:25.916230 2016] [cgi:error] [pid 8068:tid 1832] [client ::1:63120] AH01215: File "D:/xampp/htdocs/webprog/helloWorldoneform.py", line 4, in <module>\r: D:/xampp/htdocs/webprog/helloWorldoneform.py, referer: http://localhost/webprog/helloWorldoneform.html

[Sun Sep 25 13:41:25.916230 2016] [cgi:error] [pid 8068:tid 1832] [client ::1:63120] AH01215: import cgi, cgitb\r: D:/xampp/htdocs/webprog/helloWorldoneform.py, referer: http://localhost/webprog/helloWorldoneform.html

[Sun Sep 25 13:41:25.916230 2016] [cgi:error] [pid 8068:tid 1832] [client ::1:63120] AH01215: File "D:\\Python35\\lib\\cgi.py", line 38, in <module>\r: D:/xampp/htdocs/webprog/helloWorldoneform.py, referer: http://localhost/webprog/helloWorldoneform.html

[Sun Sep 25 13:41:25.916230 2016] [cgi:error] [pid 8068:tid 1832] [client ::1:63120] AH01215: import urllib.parse\r: D:/xampp/htdocs/webprog/helloWorldoneform.py, referer: http://localhost/webprog/helloWorldoneform.html

[Sun Sep 25 13:41:25.916230 2016] [cgi:error] [pid 8068:tid 1832] [client ::1:63120] AH01215: ImportError: No module named 'urllib'\r: D:/xampp/htdocs/webprog/helloWorldoneform.py, referer: http://localhost/webprog/helloWorldoneform.html

Any help would be greatly appreciated!

相关阅读:
Top