<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def flash(self, msg: str, category: Optional[str] = None):
 """ Convenience method for flashing messages. :param msg: The message to flash. :param category: The category of the message. """

        if not request.is_json and app.config.FLASH_MESSAGES:
            flash(msg, category)