def update(id): user = User.get(User.id == id) if request.method == "POST": names = request.form["names"] age = request.form["age"] weight = request.form["weight"] user.names = names user.age = age user.weight = weight user.save() flash("User Updated Successfully") return redirect(url_for('show')) return render_template('update.html', user=user)
def login(): if request.method == "POST": email = request.form["email"] password = request.form["password"] try: user = User.get(User.email == email) hashed_password = user.password if check_password_hash(hashed_password, password): flash("Logged in Successfully") session['logged_in'] = True session['names'] = user.names session['id'] = user.id return redirect(url_for('show')) except User.DoesNotExist: flash("Wrong Username or Password") return render_template("login.html")
def update(id): user = User.get(User.id == id) if request.method == "POST": names = request.form["names"] admission = request.form["admission"] hostel = request.form["hostel"] email = request.form["email"] password = request.form["password"] password = generate_password_hash(password) user.names = names user.admission = admission user.hostel = hostel user.email = email user.password = password user.save() flash("User Updated Successfully") return redirect(url_for('show')) return render_template('update.html', user=user)