Esempio n. 1
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        # login and validate the user:
        user = User.get_by_username(username=form.username.data)
        if user is not None and user.check_password(form.password.data):
            login_user(user=user, remember=form.remember_me.data)
            flash('Logged in successfully as {}'.format(user.username))
            return redirect(request.args.get('next') or url_for('index'))
        flash('Incorrect username or password')
    return render_template('login.html', form=form)
Esempio n. 2
0
def example_jinja2_usage():
    # jinja2 is an easy way to send object from server to client
    # This example describes simple usage of transfer items from db model from server to client and display it
    user = User.get_by_username('admin')
    return render_template('example_jinja.html', jinja_object=user)