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, main.py 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="https://getbootstrap.com/docs/5.2/examples/sign-in/signin.css" rel="stylesheet">
</head>
<body class="text-center">
<main class="form-signin w-100 m-auto" action = "/login" method = "post">
<form>
<img class="mb-4" src="https://getbootstrap.com/docs/5.2/assets/brand/bootstrap-logo.svg" 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>
<div class="form-floating">
<input type="password" class="form-control" id="pass" name = "pass" placeholder="Password">
<label for="pass">Password</label>
</div>
<div class="checkbox mb-3">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button>
<p class="mt-5 mb-3 text-muted">© {{params['blog_name']}} 2017–2022</p>
</form>
</main>
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, main.py 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="https://getbootstrap.com/docs/5.2/examples/sign-in/signin.css" rel="stylesheet">
</head>
<body class="text-center">
<main class="form-signin w-100 m-auto" action = "/login" method = "post">
<form>
<img class="mb-4" src="https://getbootstrap.com/docs/5.2/assets/brand/bootstrap-logo.svg" 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>
<div class="form-floating">
<input type="password" class="form-control" id="pass" name = "pass" placeholder="Password">
<label for="pass">Password</label>
</div>
<div class="checkbox mb-3">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button>
<p class="mt-5 mb-3 text-muted">© {{params['blog_name']}} 2017–2022</p>
</form>
</main>