I understand flask, I am faced with the task of implementing authorization not through a browser, but a client written in PyQt. In the flask framework, when authorizing a user who was registered and located in the SQLite database, there is a fragment of the code responsible for authorization, which I just rewrote:
@bp.route('/login', methods=('GET', 'POST')) def login(): if request.method == 'POST': username = request.get_json().get('username') password = request.get_json().get('password') #return username db = get_db() error = None user = db.execute( 'SELECT * FROM user WHERE username = ?', (username,) ).fetchone() #return user['id'] if user is None: error = 'Incorrect username.' elif not check_password_hash(user['password'], password): error = 'Incorrect password.' if error is None: #session.clear() #session['user_id'] = user['id'] return user['id'] #return user['username'] return error I can get the return value in the terminal if I return user ['username'] or user ['password'] - everything is fine with this, the request is normally executed with code 200, but I cannot return user ['id'] - I get a server error 500, which seems to me strange and incomprehensible, because there is an id in the database. Tell me, what could be the reason?
user['password']works, anduser['id']does not, then thepasswordcolumn is there, andiddoes not - suit