@app.route("/login", methods= ['POST','GET'])
def login():
session = []
msg = ''
if request.method == 'POST' and 'username' in request.form and 'password' in request.form:
# getting input with name = username in HTML form
username = request.form.get("username")
# getting input with name = password in HTML form
password = request.form.get("password")
query = "select * from person where username = '{}' and pwd = '{}'".format(username,password)
rus = connection(query)
if rus:
for i in rus:
session.append(i)
# Redirect to Home Page
return 'Logged in successfully!'
else:
#Account doesn't Exist or uname / pass incorrect
return 'Incorrect username / Password'
return render_template("login.html")
Here rus stores values from sql query i want to use this variable as for a session Navigation bar under there names