Wait! This is in Project feedback section, does that mean that we have to make something of this sort when we’re at freecodecamp? I’d love it if it’s like that!
I kind of liked to make it into a dark mode-type thing. Bright colors are sometimes a bit hard on my eyes and others’ too. I think I’ll keep it that way.
I don’t exactly know how to do that. I made this in Python Flask and I’m not too familiar with it yet.
Yeah, I tried to make it responsive as best as I could. Maybe I’ll update it later.
Here is some sample code. This is how you could set up the login to only verify email address. This uses flask, flask-wtf, flask-login, and flask-bcrypt.
@app.route('/login', methods=['GET', 'POST'])
def login_route():
'''Login registered users'''
form = LoginForm()
# If the for validates on the POST request check email and password.
if form.validate_on_submit():
# Check the database for the email address.
user = User.query.filter_by(email=form.email.data).first()
# If the email exists and the password is correct log the user in.
if user and bcrypt.check_password_hash(user.password,
form.password.data):
login_user(user)
flash('Login successful!', 'success')
# Redirect user to the profile page upon successful login.
return redirect(url_for('profile_route'))
else:
flash('Login failed. Check your email/password.', 'fail')
# Send user back to the login page if email and password are incorrect.
return redirect(url_for('login_route'))
return render_template('login.html', form=form)