Download chat2.html from DMTuit/web_soc: direct link, hf CLI and curl.
- Browser
- Download file 941 Bytes
-
https://huggingface.co/spaces/DMTuit/web_soc/resolve/main/chat2.html
- Command line
-
hf download hf://spaces/DMTuit/web_soc/chat2.html
-
curl -L -o chat2.html https://huggingface.co/spaces/DMTuit/web_soc/resolve/main/chat2.html
941 Bytes
| <html > | |
| <head> | |
| <meta charset="utf-8"> | |
| <title> | |
| Работа с сокетами на python | |
| </title> | |
| </head> | |
| <body> | |
| <div class="message"></div> | |
| <textarea placeholder="Для отправки нажмите Enter"></textarea> | |
| <script> | |
| var socket = new WebSocket("ws://dmtuit-web-soc-chat.hf.space:7860"); | |
| socket.onopen = function(){ | |
| document.querySelector("textarea").addEventListener('keyup', function(e){ | |
| if(e.keyCode === 13){ | |
| if(this.value.trim() === ""){ | |
| return false; | |
| } | |
| socket.send(this.value.trim()); | |
| this.value = ""; | |
| } | |
| }); | |
| }; | |
| socket.onerror = function(){ | |
| console.log('Ошибка при подключении'); | |
| }; | |
| var p = ""; | |
| socket.onmessage = function(e){ | |
| p = document.createElement("p"); | |
| p.innerHTML = e.data; | |
| document.querySelector(".message").appendChild(p); | |
| }; | |
| </script> | |
| </html> |