0

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>''')
4
  • but it doesn't run the python3 one Are there no errors in the server log? Commented Aug 21, 2013 at 20:44
  • Where should I look for the server log? The server belongs to my university. Commented Aug 21, 2013 at 22:29
  • @user2705123 - depends on the server. For apache, try /var/log/apache2/error.log (if you have access to that). The code should work, check the permissions of the script, and that python3.2 really is on the default path (cgi scripts don't source ~/.profile etc.) Commented Aug 22, 2013 at 10:30
  • Did you make the python3 script executable? Commented Jul 8, 2014 at 16:59

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.