File size: 2,710 Bytes
40f3dcd b15a70c 40f3dcd b15a70c 40f3dcd b15a70c 40f3dcd b15a70c 40f3dcd b15a70c 40f3dcd b15a70c 40f3dcd b15a70c 40f3dcd b15a70c 40f3dcd b15a70c 40f3dcd b15a70c 7ef8775 b15a70c 7ef8775 b15a70c 7ef8775 b15a70c a172f1d b15a70c a172f1d b15a70c 40f3dcd b15a70c 92018fe b15a70c 40f3dcd b15a70c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
<!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>
|