Athtestai / templates /index.html
Artificial-superintelligence's picture
Create templates/index.html
c738408 verified
raw
history blame
2.08 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Terminal</title>
<style>
body {
font-family: monospace;
background-color: #1e1e1e;
color: #00ff00;
padding: 20px;
}
#terminal {
width: 100%;
height: 400px;
background: black;
color: green;
padding: 10px;
overflow-y: scroll;
}
input[type="text"] {
background: black;
color: green;
border: none;
width: 100%;
font-size: 1em;
}
</style>
</head>
<body>
<div id="terminal"></div>
<input type="text" id="command" placeholder="Enter your command here..." autofocus/>
<script>
const terminal = document.getElementById("terminal");
const commandInput = document.getElementById("command");
commandInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
const command = commandInput.value;
commandInput.value = ''; // Clear input
terminal.innerHTML += `> ${command}\n`; // Show command in terminal
// Send the command to the backend
fetch('/run_command', {
method: 'POST',
body: new URLSearchParams({ 'command': command }),
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
})
.then(response => response.json())
.then(data => {
terminal.innerHTML += `${data.output}\n`; // Show output in terminal
terminal.scrollTop = terminal.scrollHeight; // Scroll to the bottom
})
.catch(error => {
terminal.innerHTML += `Error: ${error}\n`;
});
}
});
</script>
</body>
</html>