def home(): builder.main() if 'username' in session: #if user is logged in print("YOU ARE LOGGED IN MICHELLE. ") return render_template("home2.html") else: print("YOU ARE NOT LOGGED IN MICHELLE. ") return render_template("login.html")
#PwdPwd - Ivan Zhang and Qian Zhou #SoftDev1 pd7 #K #17: Average, ... or Basic? #2018-10-06 import sqlite3 #enable control of an sqlite database import csv #facilitates CSV I/O import db_builder #========================================================== db_builder.main() DB_FILE="discobandit.db" db = sqlite3.connect(DB_FILE) #open if file exists, otherwise create c = db.cursor() #facilitate db ops #======================== our hw =============================== def name_to_id(name): #Given a student's name, returns their id number, otherwise None cmd = 'SELECT id FROM peeps WHERE name = "{}"'.format(name) cur = c.execute(cmd) i_d = cur.fetchone() if i_d: return i_d[0] return None def id_to_name(id): cmd = 'SELECT name FROM peeps WHERE id = "{}"'.format(id) cur = c.execute(cmd) nomen = cur.fetchone() if nomen: return nomen[0] return None #print(name_to_id('alison'))