Athspi / templates /index.html
Artificial-superintelligence's picture
Update templates/index.html
b15a70c verified
raw
history blame
2.71 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Python Terminal</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
#terminal {
width: 100%;
height: 300px;
background: #000;
color: #0f0;
overflow-y: auto;
padding: 10px;
border-radius: 5px;
}
#input-area {
display: flex;
margin-top: 10px;
}
#command-input {
flex: 1;
padding: 10px;
font-size: 16px;
}
button {
padding: 10px 15px;
font-size: 16px;
margin-left: 5px;
}
.audio-link {
margin-top: 10px;
}
</style>
</head>
<body>
<h1>Python Terminal</h1>
<div id="terminal"></div>
<div id="input-area">
<input type="text" id="command-input" placeholder="Enter Python or shell command">
<button onclick="runCommand()">Run</button>
</div>
<div id="audio-container"></div>
<script>
const terminal = document.getElementById("terminal");
const commandInput = document.getElementById("command-input");
const audioContainer = document.getElementById("audio-container");
function appendToTerminal(text) {
terminal.innerHTML += text + "<br>";
terminal.scrollTop = terminal.scrollHeight;
}
async function runCommand() {
const command = commandInput.value;
if (!command.trim()) return;
appendToTerminal("> " + command);
commandInput.value = "";
try {
const response = await fetch("/run", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ command }),
});
const result = await response.json();
if (result.output) appendToTerminal(result.output);
if (result.error) appendToTerminal("<span style='color:red'>" + result.error + "</span>");
if (result.audio_file) {
const audioLink = `<a href="/download/${result.audio_file}" target="_blank" class="audio-link">Download/Play Audio</a>`;
audioContainer.innerHTML = audioLink;
}
} catch (error) {
appendToTerminal("<span style='color:red'>Error: " + error.message + "</span>");
}
}
</script>
</body>
</html>