Article 5MJPJ error of running python code as cgi?

error of running python code as cgi?

by
shams
from LinuxQuestions.org on (#5MJPJ)
This is index.html:
Code:<form action = "/cgi-bin/hello_get.py" method = "get">
First Name: <input type = "text" name = "first_name"> <br />
Last Name: <input type = "text" name = "last_name" />
<input type = "submit" value = "Submit" />
</form>and This is hello_get.py, i put in the /srv/http/cgi-bin:
Code:#!/usr/bin/python
# Import modules for CGI handling
import cgi, cgitb
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from fields
first_name = form.getvalue('first_name')
last_name = form.getvalue('last_name')
print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>"
print "<title>Hello - Second CGI Program</title>"
print "</head>"
print "<body>"
print "<h2>Hello %s %s</h2>" % (first_name, last_name)
print "</body>"
print "</html>when i click the submit button get the error:
Code:Server error!

The server encountered an internal error and was unable to complete your request.

Error message:
End of script output before headers: hello_get.py

If you think this is a server error, please contact the webmaster.
Error 500
my.example.net
Apache/2.4.48 (Unix) mod_fcgid/2.3.9 mod_wsgi/4.8.0 Python/3.9i can run the .pl and .sh codes from the /srv/http/cgi-bin but get the above error with all .py codes when running from the cgi-bin directory.latest?d=yIl2AUoC8zA latest?i=sEQ2oQ29sp0:asxll1_tRJo:F7zBnMy latest?i=sEQ2oQ29sp0:asxll1_tRJo:V_sGLiP latest?d=qj6IDK7rITs latest?i=sEQ2oQ29sp0:asxll1_tRJo:gIN9vFwsEQ2oQ29sp0
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments