!DOCTYPE htmlhtmlhead titleWeb Pingtitle script src=httpscdnjscloudflarecomajaxlibssocketio304socketiojsscriptheadbody h1Web Pingh1 button id=start-buttonStartbutton button id=stop-butt
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/3.0.4/socket.io.js"></script>
Web Ping
<script>
var socket = io.connect('http://' + document.domain + ':' + location.port);
var outputDiv = document.getElementById('output');
var outputLines = [];
socket.on('stream_output', function(output) {
outputLines.push(output);
if (outputLines.length > 10) {
outputLines.shift();
}
outputDiv.innerHTML = outputLines.join('<br>');
});
document.getElementById('start-button').addEventListener('click', function() {
fetch('/start', {method: 'POST'})
.then(response => response.json())
.then(data => console.log(data));
});
document.getElementById('stop-button').addEventListener('click', function() {
fetch('/stop', {method: 'POST'})
.then(response => response.json())
.then(data => console.log(data));
});
</script>
原文地址: http://www.cveoy.top/t/topic/iSFu 著作权归作者所有。请勿转载和采集!