Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago