Chris4K commited on
Commit
885c512
·
verified ·
1 Parent(s): e946edc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -50,6 +50,7 @@ html = """
50
  };
51
 
52
  function sendMessage() {
 
53
  let input = document.getElementById("inputbox");
54
  let message = input.value.trim();
55
  if (message) {
@@ -57,6 +58,22 @@ html = """
57
  input.value = "";
58
  }
59
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  </script>
61
  </body>
62
  </html>
 
50
  };
51
 
52
  function sendMessage() {
53
+ console.log("sending .... ")
54
  let input = document.getElementById("inputbox");
55
  let message = input.value.trim();
56
  if (message) {
 
58
  input.value = "";
59
  }
60
  }
61
+
62
+
63
+
64
+ ws.onopen = function() {
65
+ console.log("WebSocket connected!");
66
+ socket.send("Hello AI!"); // Send message to backend once the connection is open.
67
+ };
68
+
69
+ ws.onmessage = function(event) {
70
+ console.log("Message from server: ", event.data); // Logs the AI/system message.
71
+ };
72
+
73
+ ws.onerror = function(error) {
74
+ console.error("WebSocket Error: ", error);
75
+ };
76
+
77
  </script>
78
  </body>
79
  </html>