Flask Signals Connecting to signals


Use a signal's connect method to connect a function to a signal. When a signal is sent, each connected function is called with the sender and any named arguments the signal provides.

from flask import template_rendered

def log_template(sender, template, context, **kwargs):
        'Rendered template %(template)r with context %(context)r.',
        template=template, context=context


See the documentation on built-in signals for information about what arguments they provides. A useful pattern is adding a **kwargs argument to catch any unexpected arguments.