def login():
    # Here we use a class of some kind to represent and validate our
    # client-side form data. For example, WTForms is a library that will
    # handle this for us, and we use a custom LoginForm to validate.
    form = LoginForm()
    if form.validate_on_submit():
        # Login and validate the user.
        # user should be an instance of your `User` class
        login_user(user)

        Flask.flash('Logged in successfully.')

        next = Flask.request.args.get('next')
        # next_is_valid should check if the user has valid
        # permission to access the `next` url
        if not next_is_valid(next):
            return Flask.abort(400)

        return Flask.redirect(next or Flask.url_for('index'))
    return Flask.render_template('login.html', form=form)
Example #2
0
def perfect_pitch():
    return Flask.render_template('index.html')