#!/usr/bin/env /s/bin/python2.4 # # Basic CGI example - add two numbers import cgi # We need the header no matter what: print 'Content-Type: text/html' print print '' print '' print 'The Incredible Adding Machine Answers!' print '' form = cgi.FieldStorage() if not (form.has_key("X") and form.has_key("Y")): print "

Error

" print "

Please fill out both fields.

" else: try: X = float(form["X"].value) # all CGI values strings Y = float(form["Y"].value) print "

The answer is %s.

" % (X + Y) except ValueError: print "

Error

" print "

Both fields must be numbers.

" print ' ' # EOF