I am creating a small application where I created a directory containing a blueprint containing all the pages that are referable to the logged in user, but when the user logs in and is redirected to your page I can not work with flask-login, current_user does not work Anyway, if you can help, I would appreciate it. '
main file ( init .py)
from flask import Flask
from flask_login import LoginManager
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
app=Flask(__name__)
app.config.from_object('settings')
db=SQLAlchemy(app)
login_manager=LoginManager()
login_manager.init_app(app)
migrate=Migrate(app,db)
from app.users.users import perfil
app.register_blueprint(perfil)
from app.controllers import urls
from app.users.models.userdb import Users
blueprint file (users.py)
from flask import Blueprint,redirect,url_for,render_template
from app.users.models.userdb import Users
from flask_login import login_user,login_required,logout_user,current_user
perfil=Blueprint('perfil',__name__,url_prefix='/perfil',static_folder='static',template_folder='templates')
from app import db,login_manager
@login_manager.user_loader
def loader_user(id):
return Users.query.filter_by(id=id).first()
@login_manager.unauthorized_handler
def error():
return redirect(url_for('index'))
@perfil.route("/")
def home():
return render_template('user.html')