MCPcopy Index your code
hub / github.com/rawpython/remi / notification_message

Method notification_message

remi/server.py:544–565  ·  view source on GitHub ↗

This function sends "javascript" message to the client, that executes its content. In this particular code, a notification message is shown

(self, title, content, icon="")

Source from the content-addressed store, hash-verified

542 self._send_spontaneous_websocket_message(_MSG_JS + code)
543
544 def notification_message(self, title, content, icon=""):
545 """This function sends "javascript" message to the client, that executes its content.
546 In this particular code, a notification message is shown
547 """
548 code = """
549 var options = {
550 body: "%(content)s",
551 icon: "%(icon)s"
552 }
553 if (!("Notification" in window)) {
554 alert("%(content)s");
555 }else if (Notification.permission === "granted") {
556 var notification = new Notification("%(title)s", options);
557 }else if (Notification.permission !== 'denied') {
558 Notification.requestPermission(function (permission) {
559 if (permission === "granted") {
560 var notification = new Notification("%(title)s", options);
561 }
562 });
563 }
564 """ % {'title': title, 'content': content, 'icon': icon}
565 self.execute_javascript(code)
566
567 def do_POST(self):
568 self._instance()

Callers 1

on_button_pressedMethod · 0.80

Calls 1

execute_javascriptMethod · 0.95

Tested by

no test coverage detected