Итак, я пытаюсь создать систему «входа в систему», цитаты из-за того, что безопасности больше нет.
Мой текущий код выглядит следующим образом:
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'POST':
if not request.form['user'] or not request.form['password']:
flash('Please enter all the fields', 'error')
else:
username = request.form['user']
password = request.form['password']
exists = db.session.query(User.user).filter_by(
user=username)
if exists > 0:
logged_in = True
session['username'] = username
session['logged_in'] = True
return index(exists=exists)
return render_template('login.html', exists=exists)
return render_template('login.html')
return render_template('login.html')
Однако я получаю сообщение об ошибке:
TypeError: '>' not supported between instances of 'BaseQuery' and 'int'
Что я не понимаю, потому что exists
должно возвращать целое число.
Любая помощь будет отличной, спасибо!