I'm trying to create an admin login page where when a user types the wrong password he is redirected to the same page, but when I try to do that I face this type of error, the code is given below, please tell me how can I fix it since I'm not able to solve this error.
mian.py file:
@app.route("/dashboard", methods=['GET', 'POST'])
def login():
# if he's already loggoed in
if "user" in session and session['user'] == params['admin_user']:
posts = Posts.query.all()
return render_template("dashboard.html", params=params, posts=posts)
# if he has to login
if request.method == 'POST':
username = request.form.get("uname")
userpass = request.form.get("upass")
if username == params['admin_user'] and userpass == params['admin_password']:
# set the session variable
session['user'] = username
posts = Posts.query.all()
return render_template("dashboard.html", params=params, posts=posts)
# if is not a admin
else:
return render_template('login.html', params=params)