Hi I have a login page and now i want to verify that the username and password given by the user is correct or not, for that I am using sqlite3 for verification logic and flask for rest of the code. After writing the code for authenticating the login, I am getting 405 statuscode, and a message whose pic I have included in the message.
My html form code:
<form action="/login" method="post">
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Login</button>
</form>
Flask app route : self.resource_server.route('/login', methods = ['POST'])(self.login_module)
Code for verification:
def login_module(self):
'''This function is used to do the verification model'''
if request.method == 'POST':
user_name = request.form.get('username')
password = request.form.get('password')
if AdminLogin.login_verification(user_name, password):
return render_template('admin_dashboard.html')
else:
self.block_user()
# This function is inside another class in another file
def login_verification(self, uname, pwd):
'''This function is used to authenticate the login'''
query = "SELECT * FROM admin WHERE admin_id=?"
self.admin_cur.execute(query, (uname,))
record = self.admin_cur.fetchone()
if record and check_password_hash(record[3], pwd):
return True
else:
return False
def block_user(Self):
'''This function is used to render an access denied screen on the server'''
return render_template('access_denied.html')```