|
<!DOCTYPE html> |
|
<html lang="en"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
<title>Terminal Emulator</title> |
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/xterm.css"> |
|
</head> |
|
<body> |
|
<div id="terminal"></div> |
|
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/xterm.js"></script> |
|
<script> |
|
const term = new Terminal({ cursorBlink: true }); |
|
term.open(document.getElementById('terminal')); |
|
|
|
const socket = new WebSocket('ws://localhost:6060'); |
|
|
|
term.onData((input) => { |
|
socket.send(input); |
|
}); |
|
|
|
socket.onmessage = (event) => { |
|
term.write(event.data); |
|
}; |
|
</script> |
|
</body> |
|
</html> |
|
|