Spaces:
BG5
/
Sleeping

BG5 commited on
Commit
e44d5f8
·
verified ·
1 Parent(s): b4d6160

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +19 -17
templates/index.html CHANGED
@@ -3,28 +3,30 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Interactive WebShell</title>
7
- <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js"></script>
 
 
 
 
8
  </head>
9
  <body>
10
- <h1>Interactive Web</h1>
11
- <input type="text" id="command" placeholder="Enter command" style="width: 80%;">
12
- <button onclick="executeCommand()">Execute</button>
13
- <h2>Output:</h2>
14
- <pre id="output"></pre>
15
-
16
  <script>
17
- var socket = io();
18
 
19
- function executeCommand() {
20
- var command = document.getElementById('command').value;
21
- socket.emit('execute_command', command);
22
- }
23
 
24
- socket.on('command_output', function(data) {
25
- var output = document.getElementById('output');
26
- output.innerHTML += data.output + '\n';
 
 
 
27
  });
28
  </script>
29
  </body>
30
- </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Bash Shell</title>
7
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.0/socket.io.js"></script>
8
+ <style>
9
+ body { font-family: monospace; }
10
+ #output { white-space: pre; }
11
+ </style>
12
  </head>
13
  <body>
14
+ <div id="output"></div>
15
+ <input id="input" autofocus />
 
 
 
 
16
  <script>
17
+ const socket = io();
18
 
19
+ socket.on('output', function(data) {
20
+ document.getElementById('output').innerText += data;
21
+ });
 
22
 
23
+ document.getElementById('input').addEventListener('keydown', function(event) {
24
+ if (event.key === 'Enter') {
25
+ const input = this.value;
26
+ socket.emit('input', input);
27
+ this.value = '';
28
+ }
29
  });
30
  </script>
31
  </body>
32
+ </html>