# load up the CGI library
import cgi
# print HTTP/HTML headers
# MOD: needed to change the HTML title from Add to Divide
print """Content-type: text/html
Integer Divide Script
"""
# give me the form data
form = cgi.FieldStorage()
# default values
left = ''
right = ''
total = '?'
error = ''
# is there form data?
if 'left' in form and 'right' in form:
left = form['left'].value
right = form['right'].value
# make sure these are numbers
if left.isdigit() and right.isdigit():
# MOD: added a check to prevent divide by zero
if int(right) == 0:
error = 'ERROR: divide by zero!'
else:
# all is OK, divide the numbers!
total = str(int(left) / int(right)) # MOD: needed to change the math operator to divide
else:
error = 'ERROR: non-integer used as input!'
# printing the form
print ''