In this tutorial, we are going to use flask login library for our app user authentication. So let's get started, How to use this. First, create a project folder and in this folder make a virtual environment for our project. Here I am using pipenv for virtual environment. Now install required python packages for our project. flask pip install Flask flask-login pip install Flask-Login flask-SQLalchemy pip install Flask-SQLAlchemy Now create a file models.py for database model. from flask_sqlalchemy import SQLAlchemy from werkzeug.security import generate_password_hash, check_password_hash from flask_login import UserMixin db = SQLAlchemy() class UserModel (UserMixin, db . Model): __tablename__ = 'users' id = db . Column(db . Integer, primary_key = True ) email = db . Column(db . String( 80 ), unique = True ) username = db . Column(db . String( 100 )) password_hash = db . Column(db . String()) def set_password ( self ,pas...
Comments
Post a Comment