Complete the code to import the decorator function from Flask-Login.
from flask_login import [1]
The login_required decorator is imported from flask_login to protect routes.
Complete the code to protect the route so only logged-in users can access it.
@[1] def dashboard(): return "Welcome to your dashboard!"
The login_required decorator is placed above the route function to restrict access.
Fix the error in the decorator usage to properly protect the route.
@[1] def profile(): return "User profile page"
The login_required decorator should be used without parentheses unless arguments are needed.
Fill both blanks to create a route '/settings' that requires login and returns a simple message.
@[1] @[2]('/settings') def settings(): return "Settings page"
The login_required decorator protects the route defined by app.route.
Fill all three blanks to create a Flask app with a protected route '/profile' that returns a welcome message.
from flask import Flask from flask_login import [1], LoginManager app = Flask(__name__) login_manager = LoginManager() login_manager.init_app(app) @app.route('/profile') @[2] def profile(): return "Welcome, user!" if __name__ == '__main__': app.run(debug=[3])
Import and use login_required without parentheses to protect the route. Run the app with debug mode set to True for development.