def get_userdb_p(user, passw): Session = sessionmaker(bind=engine) s = Session() query = s.query(User).filter_by(username=user, password=passw) result = None if query: result = query.first() return result
def get_userdb(usern): Session = sessionmaker(bind=engine) s = Session() r = s.query(User).filter_by(username=usern) result = None if r: result = r.first() return result
def drop_userdb(user): Session = sessionmaker(bind=engine) s = Session() r = s.query(User).filter_by(username=user) if r: result = r.first() if result: s.delete(result) s.commit()
def action(): result = request.form.get("result") id = int(request.form.get("id")) rw = '' if check_answer(id, result): rw = "Correct" Session = sessionmaker(bind=engine) s = Session() our_user = s.query(User).filter_by(username=session['user']).first() our_user.answers += 1 s.commit() else: rw = "Incorrect" return render_template('answer.html', rw=rw, answer=data[id]['answer'])
def home(): if not session.get('logged_in'): Session = sessionmaker(bind=engine) s = Session() query = s.query(User) return render_template('login.html', query=query) else: size = len(data) randomq = random.randint(0, size - 1) result = get_userdb(session['user']) return render_template('riddle.html', data=data[randomq], id=randomq, correct=result.answers)