Path 1: 15 calls (1.0)

'Hello World' (8) Markup (4) 'Zap' (1) 'Zip' (1) 'This is a flash message' (1)

'message' (6) 'error' (4) 'warning' (4) 'notice' (1)

1def flash(message: str, category: str = "message") -> None:
2    """Flashes a message to the next request.  In order to remove the
3    flashed message from the session and to display it to the user,
4    the template has to call :func:`get_flashed_messages`.
5
6    .. versionchanged:: 0.3
7       `category` parameter added.
8
9    :param message: the message to be flashed.
10    :param category: the category for the message.  The following values
11                     are recommended: ``'message'`` for any kind of message,
12                     ``'error'`` for errors, ``'info'`` for information
13                     messages and ``'warning'`` for warnings.  However any
14                     kind of string can be used as category.
15    """
16    # Original implementation:
17    #
18    #     session.setdefault('_flashes', []).append((category, message))
19    #
20    # This assumed that changes made to mutable structures in the session are
21    # always in sync with the session object, which is not true for session
22    # implementations that use external storage for keeping their keys/values.
23    flashes = session.get("_flashes", [])
24    flashes.append((category, message))
25    session["_flashes"] = flashes
26    app = current_app._get_current_object()  # type: ignore
27    message_flashed.send(
28        app,
29        _async_wrapper=app.ensure_sync,
30        message=message,
31        category=category,
32    )