#!/usr/bin/env /s/bin/python2.4 # # Basic CGI example - add two numbers from wsalib import * v_x = CGITextInput("X", text="X value:") v_y = CGITextInput("Y", text="Y value:") v_sub = CGISubmit("submit") cgi = CGI(title="The Incredible Adding Machine Mark II") form = CGIForm([v_x, v_y, v_sub]) cgi.header() if form.filled_in(): try: X = float(form.data['X'].value) Y = float(form.data['Y'].value) print "
The answer is %s.
" % (X + Y) except ValueError: print "Both fields must be numbers.
" else: print form cgi.footer() # EOF