简体   繁体   中英

Python 3 cgi script doesn't work, but python 2 works

I'm new to cgi programming :) I have the following python cgi-scripts, one in python2 and the other in python3. The servers works well with the python2 script but it doesn't run the python3 one. python3.2 is installed on the server.

Here is the python2 script:

#!/usr/bin/env python

print "Content-type: text/html"
print ""
print ''' 
<html>
<head>
<title>Hello Word - First CGI Program</title>
</head>
<body>
<h2>Hello Word! This is my first CGI program</h2>
</body>
</html>'''

Here is the python3 script

#!/usr/bin/env python3.2

print("Content-type: text/html")
print("")
print(''' 
<html>
<head>
<title>Hello Word - First CGI Program</title>
</head>
<body>
<h2>Hello Word! This is my first CGI program</h2>
</body>
</html>''')

The http.server is replaced. python3 -m http.server --cgi 8000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM