-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.html
More file actions
33 lines (32 loc) · 1.14 KB
/
Copy pathinput.html
File metadata and controls
33 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<body>
<form onsubmit="return openWebSocket()">
<label for="currencyPair">Currency Pair:</label>
<select id="currencyPair">
<option value="BTCUSD">BTCUSD</option>
<option value="ETHUSD">ETHUSD</option>
<!-- Add more options as needed -->
</select>
<br>
<label for="quantity">Quantity:</label>
<input type="number" id="quantity" step="0.01">
<br>
<input type="submit" value="Send">
</form>
<div id="result"></div>
<script>
function openWebSocket() {
var currencyPair = document.getElementById('currencyPair').value;
var quantity = document.getElementById('quantity').value;
var ws = new WebSocket(`ws://localhost:8000/ws/order-book`);
ws.onopen = function (event) {
ws.send(currencyPair);
ws.send(quantity);
};
ws.onmessage = function (event) {
document.getElementById('result').innerText = 'Received: \n' + event.data;
};
return false; // Prevent form submission
}
</script>
</body>
</html>