shlogg · Early preview
Chevy Vall @gutmaster

Flask-Login Implementation Basics

Implementing user authentication with Flask-Login: install flask-login, create LoginManager class, initialize it with app, use login_user and logout_user functions, provide user_loader callback to pull user from database.

Many applications and websites need a way to keep track of and coordinate session and user information on the back end. While there are a plethora of ways to implement these features, Flask-Login easily provides us with the most important. The examples routes I'll be showing use flask-RESTful to organize the api, and I'll be showing as simple an implementation as I can manage. Let's take a look.
First, we install:

$ pip install flask-login

    
    

    
    




Next, we'll import and create our LoginManager class, then initialize it with our app, assuming that we're using a config file:...