flash#

Plugin for creating and retrieving flash messages.

class litestar.plugins.flash.FlashConfig#

Bases: object

Configuration for Flash messages.

__init__(template_config: TemplateConfig) None#
class litestar.plugins.flash.FlashPlugin#

Bases: InitPluginProtocol

Flash messages Plugin.

__init__(config: FlashConfig)#

Initialize the plugin.

Parameters:

config – Configuration for flash messages, including the template engine instance.

on_app_init(app_config: AppConfig) AppConfig#

Register the message callable on the template engine instance.

Parameters:

app_config – The application configuration.

Returns:

The application configuration with the message callable registered.

litestar.plugins.flash.flash(connection: ASGIConnection, message: str, category: str) None#

Add a flash message to the request scope.

Parameters:
  • connection – The connection instance.

  • message – The message to flash.

  • category – The category of the message.

litestar.plugins.flash.get_flashes(context: Mapping[str, Any]) Any#

Get flash messages from the request scope, if any.

Parameters:

context – The context dictionary.

Returns:

The flash messages, if any.