- Joined
- May 21, 2015
- Messages
- 2
- Reaction score
- 1
Hello I am using Mac OSX mavericks and I am new to apache2 and cgi, but have been using python for a while now.
My python script called hello.py in the cgi-executable folder is:
#!/anaconda/bin/python
import cgi, cgitb
form = cgi.FieldStorage()
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>"
my form.html file is:
<formaction="/cgi-bin/hello.py"method="get">
First Name: <inputtype="text"name="first_name"><br/>
Last Name: <inputtype="text"name="last_name"/>
<inputtype="submit"value="Submit"/>
</form>
But the input from the form doesn't go through to the python script!
but if i execute localhost/cgi-bin/hello.py?first_name=F&last_name=L
it displays HELLO F L
please tell me where to place the form.html file so it can find the hello.py cgi script
I have looked at stack overflow a lot and not found any solution. Please help!
The hello.py is in the cgi-executables folder
My python script called hello.py in the cgi-executable folder is:
#!/anaconda/bin/python
import cgi, cgitb
form = cgi.FieldStorage()
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>"
my form.html file is:
<formaction="/cgi-bin/hello.py"method="get">
First Name: <inputtype="text"name="first_name"><br/>
Last Name: <inputtype="text"name="last_name"/>
<inputtype="submit"value="Submit"/>
</form>
But the input from the form doesn't go through to the python script!
but if i execute localhost/cgi-bin/hello.py?first_name=F&last_name=L
it displays HELLO F L
please tell me where to place the form.html file so it can find the hello.py cgi script
I have looked at stack overflow a lot and not found any solution. Please help!
The hello.py is in the cgi-executables folder