def update_profile():
    if request.method == 'POST':
        password_n = request.form['password']
        user = User.query.get_or_404(current_user.id)
        if user:
            if password_n:
                user.password = User.create_password(password_n)
                flash("Password is updated successfully")
                db.session.commit()
            else:
                flash(
                    "It seems you haven't entered the password in the form. Please try again."
                )
    return render_template("update_profile.html")
def register():

    form = Registration()
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    if form.validate_on_submit():
        user = User(username=form.username.data,
                    email=form.email.data,
                    password=User.create_password(form.password.data))
        db.session.add(user)
        db.session.commit()
        flash("Registartion successful")
        return redirect(url_for('login'))
    elif form.errors:
        flash("There are some errors in form submission. Please try again")
        return redirect(url_for('register'))

    return render_template('register.html', form=form, title='Sign Up')