#!/usr/bin/python import cgitb; cgitb.enable() import os print """Content-Type: text/html\n\n""" print """\n\n""" head = open('head.html').read() % "Pflanzarr Results" print head print "

Results

" print 'Submit | Results | Documentation' try: winner = open(os.path.join('data', 'winner')).read() except: winner = "No winner yet." print "

Last Winner: ", winner, '

' print "

Results so far:

" try: games = os.listdir(os.path.join('data', 'results')) except: print '

The data directory does not exist.' games = [] if not games: print "

No games have occurred yet." gameNums = [] for game in games: try: num = int(game) path = os.path.join( 'data', "results", game, 'results.html') if os.path.exists( path ): gameNums.append( int(num) ) else: continue except: continue gameNums.sort(reverse=True) for num in gameNums: print '

%d - ' % num, print 'v' % num, print 'r' % num