Update test_websocket.html to use Caddy proxy URL and send JSON

This commit is contained in:
Ramforth
2025-10-31 18:24:22 +01:00
parent eec9c863c2
commit 4c7fad61cc

View File

@@ -9,7 +9,7 @@
<button onclick="sendMessage()">Send</button>
<ul id="messages"></ul>
<script>
const ws = new WebSocket("ws://localhost:8000/ws");
const ws = new WebSocket("wss://overlays.ramforth.net/weather_ws");
ws.onmessage = function(event) {
const messages = document.getElementById('messages');
const message = document.createElement('li');
@@ -19,8 +19,11 @@
};
function sendMessage() {
const input = document.getElementById("message");
ws.send(input.value);
input.value = '';
const location = input.value;
if (location) {
ws.send(JSON.stringify({ "location": location }));
input.value = '';
}
}
</script>
</body>