mirror of
https://github.com/hequan2017/seal.git
synced 2026-03-22 05:00:07 +08:00
53 lines
1.1 KiB
Python
53 lines
1.1 KiB
Python
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>django webssh 例子</title>
|
|
|
|
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/xterm/3.13.2/xterm.css" rel="stylesheet" type="text/css"/>
|
|
|
|
</head>
|
|
<body>
|
|
|
|
|
|
<div id="terms"></div>
|
|
</body>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/xterm/3.13.2/xterm.js"></script>
|
|
|
|
|
|
<script>
|
|
var socket = new WebSocket('ws://' + window.location.host + '/ws/{{ name }}/{{ namespace }}');
|
|
|
|
socket.onopen = function () {
|
|
|
|
var term = new Terminal();
|
|
term.open(document.getElementById('terms'));
|
|
|
|
|
|
term.on('data', function (data) {
|
|
console.log(data);
|
|
socket.send(data);
|
|
});
|
|
|
|
socket.onmessage = function (msg) {
|
|
console.log(msg);
|
|
console.log(msg.data);
|
|
term.write(msg.data);
|
|
};
|
|
socket.onerror = function (e) {
|
|
console.log(e);
|
|
};
|
|
|
|
socket.onclose = function (e) {
|
|
console.log(e);
|
|
term.destroy();
|
|
};
|
|
};
|
|
|
|
|
|
</script>
|
|
|
|
|
|
</html> |