I am beginner in CGI and trying to pass input from HTML to python (html file input to python file). i dont know where i am doing wrong. I am following tutorial from http://www.tutorialspoint.com/python/python_cgi_programming.htm and for extra help i also looked at Posting html form values to python script but failed. I am using windows 8 OS.
Here is my code: test.py
#!C:\Python27\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>"
test.html
<html>
<body>
<form name="search" action="/cgi-bintest.py" method="get">
Search: <input type="text" name="searchbox">
<input type="submit" value="Submit">
</form>
</form>
</body>
</html>
On chrome: when i write "http://localhost/cgi-bin/test.html"
it gives:
Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500
localhost
Apache/2.4.16 (Win32) OpenSSL/1.0.1p PHP/5.6.12
Note: I have placed both files i.e test.py and test.html in "cgi-bin" is that correct? as i am coming from php, javascript etc background.
Kindly help plz if am doing wrong?