July 2018
Intermediate to advanced
324 pages
8h 14m
English
Flask implemented the views in a very flexible way, where you can define the routes along with them. Flask's generic views implementation is inspired by Django's generic views. We will look at a detailed description of method views in a further section, but here, we are going to use simple views.
The following is the views snippet.
File—auth/views.py:
from flask import render_template, redirect, url_forfrom flask_login import login_user, login_required, logout_userfrom app.auth import authfrom app.auth.forms import LoginForm, SignupFormfrom app.auth.models import User@auth.route('/login', methods=['GET', 'POST'])def login(): form = LoginForm() if form.validate_on_submit(): user_by_email = User.query.filter_by(email=form.email.data).first() ...Read now
Unlock full access