DmitrMakeev
commited on
Commit
•
783bbf0
1
Parent(s):
9c23a1d
Create chat.html
Browse files
chat.html
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<title>Flask SocketIO Chat</title>
|
5 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.1.2/socket.io.js"></script>
|
6 |
+
<script>
|
7 |
+
var socket = io();
|
8 |
+
|
9 |
+
function sendMessage() {
|
10 |
+
var message = document.getElementById("messageInput").value;
|
11 |
+
socket.emit('message', message);
|
12 |
+
document.getElementById("messageInput").value = '';
|
13 |
+
}
|
14 |
+
|
15 |
+
socket.on('message', function(message) {
|
16 |
+
var chat = document.getElementById('chat');
|
17 |
+
var p = document.createElement('p');
|
18 |
+
p.innerText = message;
|
19 |
+
chat.appendChild(p);
|
20 |
+
});
|
21 |
+
</script>
|
22 |
+
</head>
|
23 |
+
<body>
|
24 |
+
<div id="chat"></div>
|
25 |
+
<input type="text" id="messageInput" />
|
26 |
+
<button onclick="sendMessage()">Send</button>
|
27 |
+
</body>
|
28 |
+
</html>
|