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

Joined
Dec 24, 2022
Messages
1
Reaction score
0
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">&copy; {{params['blog_name']}} 2017–2022</p>
</form>
</main>
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top