<html>
<head>
<script src="https://cdn.socket.io/4.5.4/socket.io.min.js"></script>
<script>
var socket = io("http://localhost:8000");
socket.on("connect", function() {
    console.log("Connected to Socket.IO server");
});
socket.on("message", function(data) {
    document.getElementById("output").innerHTML += data + "<br>";
});
function sendMessage() {
    var message = document.getElementById("message").value;
    socket.send(message);
    document.getElementById("message").value = "";  // Clear input after sending
}
window.onbeforeunload = function() {
    socket.disconnect();
};
</script>
</head>
  <body>
    <h1>Socket.IO Chat</h1>
    <input type="text" id="message" placeholder="Type a message">
    <button onclick="sendMessage()">Send</button>
    <div id="output"></div>
  </body>
</html>
