Create templates/index.html
Browse files- templates/index.html +33 -0
templates/index.html
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<title>Web-based Terminal</title>
|
5 |
+
</head>
|
6 |
+
<body>
|
7 |
+
<h1>Web-based Terminal</h1>
|
8 |
+
<div id="terminal-output"></div>
|
9 |
+
<input type="text" id="command-input" autofocus>
|
10 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.2.0/socket.io.js"></script>
|
11 |
+
<script>
|
12 |
+
var socket = io.connect('http://' + document.domain + ':' + location.port);
|
13 |
+
|
14 |
+
socket.on('connect', function() {
|
15 |
+
console.log('Connected to server');
|
16 |
+
});
|
17 |
+
|
18 |
+
socket.on('output', function(data) {
|
19 |
+
var outputDiv = document.getElementById('terminal-output');
|
20 |
+
outputDiv.innerHTML += '<pre>' + data + '</pre>';
|
21 |
+
outputDiv.scrollTop = outputDiv.scrollHeight;
|
22 |
+
});
|
23 |
+
|
24 |
+
document.getElementById('command-input').addEventListener('keypress', function(event) {
|
25 |
+
if (event.key === 'Enter') {
|
26 |
+
var command = event.target.value;
|
27 |
+
socket.emit('command', command);
|
28 |
+
event.target.value = '';
|
29 |
+
}
|
30 |
+
});
|
31 |
+
</script>
|
32 |
+
</body>
|
33 |
+
</html>
|