Static File Index-(делали на лекции).HTML 973 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!DOCTYPE html>
  2. <!-- saved from url=(0025)http://192.168.1.20:5000/ -->
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  6. <title>Static File Index.HTML</title>
  7. <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>
  8. </head>
  9. <body>
  10. <div id="formContainer"></div>
  11. <input type="text" id="nickId" />
  12. <input type="text" id="msgId" />
  13. <button id="sendId">Send msg</button>
  14. <div class="chat" id="chatId">sdfasfasfvasafvasfabvfasdfbasbfas</div>
  15. <script>
  16. const socket = io("http://192.168.1.217:4000/");
  17. socket.on("msg", function (msg) {
  18. console.log(msg);
  19. chatId.innerHTML += '<br/>' + msg.nick + ': ' + msg.message;
  20. });
  21. sendId.onclick = () => {
  22. socket.emit("msg", {
  23. nick: nickId.value,
  24. message: msgId.value,
  25. });
  26. };
  27. </script>
  28. </body>
  29. </html>