简体   繁体   English

Python 3 cgi脚本不起作用,但是python 2有效

[英]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. 我是cgi编程的新手:)我有以下python cgi-script,一个在python2中,另一个在python3中。 The servers works well with the python2 script but it doesn't run the python3 one. 这些服务器可以与python2脚本配合使用,但不能运行python3脚本。 python3.2 is installed on the server. python3.2已安装在服务器上。

Here is the python2 script: 这是python2脚本:

#!/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 这是python3脚本

#!/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. http.server被替换。 python3 -m http.server --cgi 8000 python3 -m http.server --cgi 8000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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