Problem in getting dashboard page from login page in python pycharm using POST command

Dec 24, 2022
Reaction score
please help

in Pycharm i am working on admin page but when i add password and user name it does not go to dashboard page ,,,,,,,,my code, file and login.html file and dashboard.html file is attached here. it seems that if block never runs because when i add password and username, it goes back to login page instead of dashboiard page

@app.route("/login", methods = ['GET','POST'])
def login():
if ('user' in session and session['user'] == params['admin_user']):
return render_template('dashboard.html', params=params)

if request.method =='POST':
user_name = request.form.get('uname')
user_password= request.form.get('pass')
if (user_name == params['admin_user'] and user_password == params['admin_password']):
session['user'] = user_name
return render_template('dashboard.html', params=params)

return render_template('login.html', params=params)
login.html file

<!doctype html>
<html lang="en">

<!-- Custom styles for this template -->
<link href="" rel="stylesheet">
<body class="text-center">

<main class="form-signin w-100 m-auto" action = "/login" method = "post">
<img class="mb-4" src="" alt="" width="72" height="57">
<h1 class="h3 mb-3 fw-normal">Admin Login</h1>

<div class="form-floating">
<input type="text" name = "uname" class="form-control" id="uname" placeholder="kamran135">
<label for="uname">User Name</label>
<div class="form-floating">
<input type="password" class="form-control" id="pass" name = "pass" placeholder="Password">
<label for="pass">Password</label>

<div class="checkbox mb-3">
<input type="checkbox" value="remember-me"> Remember me
<button class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button>
<p class="mt-5 mb-3 text-muted">&copy; {{params['blog_name']}} 2017–2022</p>


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question