def make_navbar(): str = cgi_utils_sda.file_contents("navbar.html") type = session.getStatus() team = session.getTeamName() #TODO if team is deleted, fix header if type == "m" or type == "c" and (team != "None" or team != "NULL" or team != None): dashboard = "<li><a href='managerDashboard.cgi'>Manage Team: "+team+"</a></li>" switch = "<li><a href='viewTeams.cgi'>Switch Team </a></li>" elif type == "p" and (team != "None" or team != None): dashboard = "<li><a href='playerDashboard.cgi'>View Team: "+team+"</a></li>" switch = "<li><a href='viewTeams.cgi'>Switch Team </a></li>" else: dashboard = "" switch = "" #logged status printed so capital L on l abel, lower l on URL if logged_status(): status = "ogout" userdash = "<li><a href='userDashboard.cgi'>My Dashboard</a></li>" settings ="<li><a href='userSettings.cgi'>Settings</a></li>" index = "#" else: status = "ogin" userdash = "" index = "index.cgi" settings = "" return str.format(index=index,userdash=userdash,dashboard=dashboard,status=status,team=team,switch=switch,settings=settings)
def insertActor(nm, name, birthdate): def main(): conn = hw5connect.connect(dsn) # functions to control insertion of actors from webpage if __name__ == '__main__': print 'Content-type: text/html\n' scriptname = sys.argv[0] form_data = cgi.FieldStorage() if form_data.has_key('username'): print ("<p>Hello %s; it's nice to meet you." % form_data['username']) else: print file_contents('name-form.html').format(script=scriptname)
def main(): form_data = {'month': ''} fillers = {} fillers['scriptname'] = os.environ['SCRIPT_NAME'] if 'SCRIPT_NAME' in os.environ else '' fs = cgi.FieldStorage() if 'month' in fs: month = int(fs.getFirst('month')) fillers['monthname'] = month_names[month] fillers['actorlist'] = actorNamesByMonth.main(month) fillers['monthmenu'] = generate_month_menu(month) else: fillers['monthname'] = 'None' fillers['actorlist'] = '' fillers['monthmenu'] = generate_month_menu(0) tmpl = file_contents('actorNamesByMonth.tmpl') fillers['footer'] = file_contents('footer.part') return tmpl.format(**fillers)
def main(): form_data = {'month': ''} fillers = {} fillers['scriptname'] = os.environ[ 'SCRIPT_NAME'] if 'SCRIPT_NAME' in os.environ else '' fs = cgi.FieldStorage() if 'month' in fs: month = int(fs.getFirst('month')) fillers['monthname'] = month_names[month] fillers['actorlist'] = actorNamesByMonth.main(month) fillers['monthmenu'] = generate_month_menu(month) else: fillers['monthname'] = 'None' fillers['actorlist'] = '' fillers['monthmenu'] = generate_month_menu(0) tmpl = file_contents('actorNamesByMonth.tmpl') fillers['footer'] = file_contents('footer.part') return tmpl.format(**fillers)
def print_header(title): str = cgi_utils_sda.file_contents('header.html') return str.format(title=title)
dsn['database'] = 'wmdb' conn = hw5connect.connect(dsn) return get # functions to control insertion of actors from webpage if __name__ == '__main__': print 'Content-type: text/html\n' scriptname = sys.argv[0] form_data = cgi.FieldStorage() if form_data.has_key('username'): print ("<p>Hello %s; it's nice to meet you." % form_data['username']) else: print file_contents('hw5page.html').format(script=scriptname) #===================================================== def insertActor(nm, name, birthdate): def main(): conn = hw5connect.connect(dsn) # functions to control insertion of actors from webpage if __name__ == '__main__': print 'Content-type: text/html\n' scriptname = sys.argv[0]
#!/usr/local/bin/python2.7 import sys import cgi import cgitb cgitb.enable() import cgi_utils_sda if __name__ == '__main__': print 'Content-type: text/html\n' form_data = cgi.FieldStorage() if 'username' in form_data: tmpl = cgi_utils_sda.file_contents('name-response.html') username = form_data.getfirst('username') page = tmpl.format(name=username) print page else: print '''Error: This script, {script}, should be given form data that includes a "username" input'''.format(script=sys.argv[0])