from flask import Flask, render_template, redirect
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField
from wtforms.validators import DataRequired, Email, Length
from flask_bootstrap import Bootstrap


# Create the form object
class MyForm(FlaskForm):
    email = StringField(label='Email', validators=[DataRequired(),
                                                   Email(message="That's not a valid email address.")])
    password = PasswordField(label='Password', validators=[DataRequired(), Length(min=8)])
    submit = SubmitField(label='Log In')


app = Flask(__name__)
# Add Bootstrap to the app
Bootstrap(app)
# Secret Key required by WTForms
app.secret_key = "totallysecret"


@app.route("/")
def home():
    return render_template('index.html')


@app.route('/login', methods=['GET', 'POST'])
def login():
    form = MyForm()
    # Check the login credentials
    if form.validate_on_submit():
        if form.email.data == '<EMAIL>' and form.password.data == '<PASSWORD>':
            return redirect('success')
        return redirect('denied')
    return render_template('login.html', form=form)


@app.route('/success')
def success():
    return render_template('success.html')


@app.route('/denied')
def denied():
    return render_template('denied.html')


if __name__ == '__main__':
    app.run(debug=True)

from flask import Flask, render_template, redirect
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField
from wtforms.validators import DataRequired, Email, Length
from flask_bootstrap import Bootstrap


# Create the form object
class MyForm(FlaskForm):
    email = StringField(label='Email', validators=[DataRequired(),
                                                   Email(message="That's not a valid email address.")])
    password = PasswordField(label='Password', validators=[DataRequired(), Length(min=8)])
    submit = SubmitField(label='Log In')


app = Flask(__name__)
# Add Bootstrap to the app
Bootstrap(app)
# Secret Key required by WTForms
app.secret_key = "totallysecret"


@app.route("/")
def home():
    return render_template('index.html')


@app.route('/login', methods=['GET', 'POST'])
def login():
    form = MyForm()
    # Check the login credentials
    if form.validate_on_submit():
        if form.email.data == '<EMAIL>' and form.password.data == '<PASSWORD>':
            return redirect('success')
        return redirect('denied')
    return render_template('login.html', form=form)


@app.route('/success')
def success():
    return render_template('success.html')


@app.route('/denied')
def denied():
    return render_template('denied.html')


if __name__ == '__main__':
    app.run(debug=True)

# Create the form object # Add Bootstrap to the app # Secret Key required by WTForms # Check the login credentials