#!/usr/bin/env python
import cgi
header = 'Content-Type: text/html\n\n'
formhtml = '''
Lotto picks just for your (static screen)
Lotto picks just for your (static screen)
Lotto picks just for you!
''' fradio = ' %s\n' def showForm(): friends = [] for i in (0, 10, 25, 50, 100): checked = '' if i == 0: checked = 'CHECKED' friends.append(fradio % (str(i), checked, str(i))) print '%s%s' % (header, formhtml % ''.join(friends)) reshtml = '''Lotto picks calculated for: %s
Your name is: %sYou have %s friends. ''' def doResults(who, howmany): print header + reshtml % (who, who, howmany) def process(): form = cgi.FieldStorage() if 'person' in form: who = form['person'].value else: who = 'NEW USER' if 'howmany' in form: howmany = form['howmany'].value else: howmany = 0 if 'action' in form: doResults(who, howmany) else: showForm() if __name__ == '__main__': process()