#๐Ÿ”’ need help in resolving 405 error

10 messages ยท Page 1 of 1 (latest)

still robin
#

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')```
dreamy parcelBOT
#

@still robin

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

still robin
#

full code can be seen in this repository :

wooden pulsar
#

@still robin were you able to figure it out?

#

i think it doesnt like you sending a POST request to your login

#

i dont see any decorators on your functions either

dreamy parcelBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.