Question: I am having trouble getting my login working for a python flask project. The code below seems to only check the first line of the

I am having trouble getting my login working for a python flask project. The code below seems to only check the first line of the file that stores the passwords:

@app.route('/login', methods=['GET', 'POST']) def login(): """Function to Login""" if request.method == 'POST': file = open("data_storage.txt", "r") data = file.readlines() file.close() data = [x.split() for x in data] for items in data: #Read just the email and password #email = request.form['email'] print(data) if request.form['email'] == items[0].strip() and request.form['pass' 'word']==items[1].strip(): session['visited'] = True #Check if the user has already logged in return redirect(url_for('index')) #Once logged in redirect to index else: #Message if login information is not found in the data file error = "That is not valid login information" format_log = logging.Formatter('%(asctime)s %(levelname)s %(message)s') logger_create ("invalid_login.log", format_log , logging.INFO, invalid_login_info()) return render_template("login.html", error=error) else: return render_template("login.html")

data_storage.txt:

user1@mail.address Password11** mbartoon@mail.address Password11**

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!