I've looked at this a million times over and couldn't be more frustrated and I know I'm doing something stupid, but I can't put my finger on it.
I've written all the code in html and in python, but whenever I test the CGI script with the site, everything seems to sync up.
The form part of my html code says:
<form method="POST" action="cgi-bin/~cgi.py">
<input type="text" name="num1">
<input type="text" name="num2">
<input type=submit value="Okay.">
</form>
And the CGI script written in python is:
#!/usr/local/bin/python
import cgitb; cgitb.enable()
import cgi
def main():
form = cgi.FieldStorage()
print "Content-type: text/html"
print
if not form:
print "<h1>No Form Keys</h1>"
else:
print "<h1>Form Keys</h1>"
for key in form.keys():
value = form[key].value
print "<p>", cgi.escape(key), ":", cgi.escape(value)
if __name__ == "__main__":
main()
The directory the html is stored in is /desktop/Test.htm and the file the directory the python is stored in is /desktop/cgi-bin/~cgi.py. I've tried it on two different browsers, (both accepting scripts) checked and double-checked that the file names match up, check the default directory that my python runs in, and obey MIME syntax as best as I know how, but whenever I open the site and type anything into the fields, the page it redirects me to is titled:
file:///.../cgi-bin/~cgi.py
and all it shows is the plaintext code of the python. Running on mac OS X 10.5. Anybody have any clue what's wrong?
I've written all the code in html and in python, but whenever I test the CGI script with the site, everything seems to sync up.
The form part of my html code says:
<form method="POST" action="cgi-bin/~cgi.py">
<input type="text" name="num1">
<input type="text" name="num2">
<input type=submit value="Okay.">
</form>
And the CGI script written in python is:
#!/usr/local/bin/python
import cgitb; cgitb.enable()
import cgi
def main():
form = cgi.FieldStorage()
print "Content-type: text/html"
if not form:
print "<h1>No Form Keys</h1>"
else:
print "<h1>Form Keys</h1>"
for key in form.keys():
value = form[key].value
print "<p>", cgi.escape(key), ":", cgi.escape(value)
if __name__ == "__main__":
main()
The directory the html is stored in is /desktop/Test.htm and the file the directory the python is stored in is /desktop/cgi-bin/~cgi.py. I've tried it on two different browsers, (both accepting scripts) checked and double-checked that the file names match up, check the default directory that my python runs in, and obey MIME syntax as best as I know how, but whenever I open the site and type anything into the fields, the page it redirects me to is titled:
file:///.../cgi-bin/~cgi.py
and all it shows is the plaintext code of the python. Running on mac OS X 10.5. Anybody have any clue what's wrong?