Victor Subervi wrote:
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
You get here if num == '', so you're printing out an empty string!
BTW, try not to use bare excepts.
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?
--
http://mail.python.org/mailman/listinfo/python-list