MCPcopy Create free account
hub / github.com/pallets/quart / flash

Function flash

src/quart/helpers.py:99–124  ·  view source on GitHub ↗

Add a message (with optional category) to the session store. This is typically used to flash a message to a user that will be stored in the session and shown during some other request. For example, .. code-block:: python @app.route('/login', methods=['POST']) async

(message: str, category: str = "message")

Source from the content-addressed store, hash-verified

97
98
99async def flash(message: str, category: str = "message") -> None:
100 """Add a message (with optional category) to the session store.
101
102 This is typically used to flash a message to a user that will be
103 stored in the session and shown during some other request. For
104 example,
105
106 .. code-block:: python
107
108 @app.route('/login', methods=['POST'])
109 async def login():
110 ...
111 await flash('Login successful')
112 return redirect(url_for('index'))
113
114 allows the index route to show the flashed messages, without
115 having to accept the message as an argument or otherwise. See
116 :func:`~quart.helpers.get_flashed_messages` for message retrieval.
117 """
118 flashes = session.get("_flashes", [])
119 flashes.append((category, message))
120 session["_flashes"] = flashes
121 app = current_app._get_current_object() # type: ignore
122 await message_flashed.send_async(
123 app, _sync_wrapper=app.ensure_async, message=message, category=category
124 )
125
126
127def get_flashed_messages(

Callers 3

test_flashFunction · 0.90
test_flash_categoryFunction · 0.90

Calls 2

appendMethod · 0.80
getMethod · 0.45

Tested by 3

test_flashFunction · 0.72
test_flash_categoryFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…