[Tutor] Endless loop
Alan Gauld
alan.gauld at yahoo.co.uk
Wed Oct 7 20:19:37 EDT 2020
On 08/10/2020 00:59, Mike Duncan wrote:
> Hi all.,
> I have an endless loop issue, frankly I don't know why it is stuck
Neither do I and since you have lost all the indentation (you need to
post in plain text not HTML) it is impossible to tell where any of the
loops start/end.
Please repost with the message in plain text. Then we might be able to
make a stab at it.
> @app.route ( "/auth", methods=['GET', 'POST'] )
> def authenticate_user():
> password = request.form['pwd']
> username = request.form['email']
> hash_pass = sha256_crypt.hash ( password )
> hash_user = sha256_crypt.hash ( username )
>
> userfile = open ( "user_file.txt", "r" )
> while userfile:
This might be the culprit.
You are testing if the usefile object exists. The object will
still exist even when you've read to the end of it, so the
while will run forever unless you have a break. Which you do
but I don't know where it fits in the logic, hence the need
for a repost....
> user = userfile.readline ()
> pwdd = userfile.readline ()
> blankline = userfile.readline ()
> while (blankline == ''):
> if (sha256_crypt.verify ( username, hash_user )):
> print("Good User")
> break
> userfile.close ()
> if (sha256_crypt.verify ( password, hash_pass )) & (sha256_crypt.verify ( username, hash_user )):
> print ( 'Good Login' )
> return render_template ( 'menu.html', currtime=currenttime )
> return
> else:
> print ( 'Bad Login' )
> return render_template ( 'home.html', currtime=currenttime )
> return
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list