#! /usr/bin/env python3 import cgitb; cgitb.enable() import cgi import teams import fcntl import string print('Content-type: text/html') print() f = cgi.FieldStorage() team = f.getfirst('team', '') pw = f.getfirst('pw') confirm_pw = f.getfirst('confirm_pw') html = string.Template(''' Team Registration

Team Registration

$team_error

$pw_match_error
''') if not (team and pw and confirm_pw): #If we're starting from the beginning? html = html.substitute(team_error='', pw_match_error='') elif teams.exists(team): html = html.substitute(team_error='Team team already taken', pw_match_error='') elif pw != confirm_pw: html = html.substitute(team_error='', pw_match_error='Passwords do not match') else: teams.add(team, pw) html = 'Team registered.' print(html)