[Tutor] Endless loop
Mike Duncan
nacnudskim at gmail.com
Wed Oct 7 19:59:26 EDT 2020
Hi all.,
I have an endless loop issue, frankly I don't know why it is stuck in a endless loop. I don't understand why, I am trying to add a login to a web-sight using python here is the code: (have attached a zip file with the complete web-sight)
@app.route ( "/auth", methods=['GET', 'POST'] )
def authenticate_user():
""" Authenticate a user """
# authenticated = False
# Encrypt password
password = request.form['pwd']
username = request.form['email']
# hash_pass = sha256_crypt.hash(password) # View encrypted password
# Encrypt password
hash_pass = sha256_crypt.hash ( password )
hash_user = sha256_crypt.hash ( username )
userfile = open ( "user_file.txt", "r" )
while userfile:
user = userfile.readline ()
pwdd = userfile.readline ()
blankline = userfile.readline ()
while (blankline == ''):
if (sha256_crypt.verify ( username, hash_user )):
print("Good User")
break
userfile.close ()
# print ( "Password: " + password + " crypto: " + hash_pass )
# print ( "Email: " + username + " crypto: " + hash_user )
# usr_store ( hash_user, hash_pass )
# usr_read ()
if (sha256_crypt.verify ( password, hash_pass )) & (sha256_crypt.verify ( username, hash_user )):
# return Response(str(authenticated))
print ( 'Good Login' )
return render_template ( 'menu.html', currtime=currenttime )
return
else:
print ( 'Bad Login' )
return render_template ( 'home.html', currtime=currenttime )
return
Here is the output:
127.0.0.1 - - [07/Oct/2020 17:46:39] "GET /favicon.ico HTTP/1.1" 404 -
Good User
Good User
Good User
Good User
Good User
Good User
Good User
Good User
Good User
Good User
Any help would be great
Thank you,
Mike
More information about the Tutor
mailing list