Example #1
0
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
Example #2
0
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
Example #3
0
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()
Example #4
0
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'])
Example #5
0
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)