Usually contains protected routes that require authentication. Enferno uses a pattern of protecting all routes in this blueprint automatically using before_request:
Copy
from flask import Blueprintfrom flask_security import auth_requiredportal = Blueprint('portal', __name__)# Protect all routes in this blueprint automatically@portal.before_request@auth_required()def before_request(): pass@portal.route('/dashboard')def dashboard(): return render_template('portal/dashboard.html')@portal.route('/settings')def settings(): return render_template('portal/settings.html')
This pattern ensures that all routes within the portal blueprint require authentication without needing to decorate each route individually.
Enferno uses Celery for background tasks. Tasks are defined in enferno/tasks/__init__.py:
Copy
from enferno.tasks import celery@celery.taskdef send_email(user_id, subject, message): from enferno.extensions import db from enferno.user.models import User user = db.session.get(User, user_id) # Send email to user... return True
Call tasks from anywhere in your application:
Copy
from enferno.tasks import send_email# Call task asynchronouslysend_email.delay(user.id, 'Welcome', 'Welcome to Enferno!')