Update test_websocket.html to use Caddy proxy URL and send JSON
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user