• Why can't my code run

 

Hello everyone, I train to create a website with Flask and Python. I have setup db and this is the code for my login information:

@app.route('/login/', methods=["POST","GET"])
    def loginpage():    message=""
    c, conn = connection()
try:
    if request.method=="GET":
    return render_template("login.html",message=message)
    if request.method=="POST":
    data=c.execute("SELECT * FROM user WHERE username = '%s'"%(request.form['username']) )
    data=c.fetchone()

if data==request.form['password']:
    message = "Success"
        session['loged-in']=True
        session['username']="flag{lollellul}"
return rendertemplate("login.html",message=message)
    else : message ="Unknown user" return rendertemplate("login.html",message=message)
    except Exception as e:
    message=str(e)
return render_template("login.html", message=message)

But when I test it, it always returns the error. The 'NoType' object does not have the 'getitem' attribute I edited, but it is still not better Can anybody help me with it to get?

.