Getting a Form To Work
Victor Subervi
victorsubervi at gmail.com
Sun Jul 19 11:35:58 EDT 2009
Hi;
I have the following in a *.py page for the Web:
from primeNumbers import primeNumbers
try:
num = form.getfirst('num')
except:
num = ''
msg = "Oops"
print "Content-Type: text/html"
print
print """
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<head xmlns="http://www.w3.org/1999/xhtml">
</head>
"""
if num != '':
try:
num = round(float(num))
roots = primeNumbers(num)
print roots
except:
msg += "We're sorry! You entered something that is not a number. Please
try again.<br />\n"
num = ''
if num == '':
print msg
print "Num:", num
print """
<form action="http://13gems.com/test-Calculators_frame.py" method="post">
<input type="text" name="num" size="20" maxlength="20" value="Enter number
here..." onfocus="this.value=''" />
<input type="image" src="http://13gems.com/images/search.jpg" name="search"
id="search" />
</form>
"""
print '</body></html>\n'
Now, "Oops" never gets printed, nor does the variable num (although a blank
space appears to print). I am calling the very page to which the form sends
its values. Assuming the imported module works, why donĀ“t I get anything
printed?
TIA,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090719/7d952367/attachment.html>
More information about the Python-list
mailing list