Update templates/index.html
Browse files- templates/index.html +52 -88
templates/index.html
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
<!DOCTYPE html>
|
| 3 |
<html lang="en">
|
| 4 |
<head>
|
|
@@ -8,115 +7,80 @@
|
|
| 8 |
<style>
|
| 9 |
body {
|
| 10 |
font-family: Arial, sans-serif;
|
| 11 |
-
|
| 12 |
-
color: #c7c7c7;
|
| 13 |
-
margin: 0;
|
| 14 |
-
padding: 0;
|
| 15 |
-
display: flex;
|
| 16 |
-
justify-content: center;
|
| 17 |
-
align-items: center;
|
| 18 |
-
height: 100vh;
|
| 19 |
}
|
| 20 |
-
|
| 21 |
-
width:
|
| 22 |
-
height:
|
| 23 |
-
background: #
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
|
| 27 |
-
display: flex;
|
| 28 |
-
flex-direction: column;
|
| 29 |
-
}
|
| 30 |
-
.terminal-output {
|
| 31 |
-
flex: 1;
|
| 32 |
-
background: #1e1e1e;
|
| 33 |
padding: 10px;
|
| 34 |
border-radius: 5px;
|
| 35 |
-
overflow-y: auto;
|
| 36 |
-
margin-bottom: 10px;
|
| 37 |
-
white-space: pre-wrap;
|
| 38 |
}
|
| 39 |
-
|
| 40 |
display: flex;
|
|
|
|
| 41 |
}
|
| 42 |
-
input {
|
| 43 |
flex: 1;
|
| 44 |
padding: 10px;
|
| 45 |
-
|
| 46 |
-
border: 1px solid #444;
|
| 47 |
-
background: #1e1e1e;
|
| 48 |
-
color: #c7c7c7;
|
| 49 |
}
|
| 50 |
button {
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
border-radius: 5px;
|
| 55 |
-
background: #0078d4;
|
| 56 |
-
color: white;
|
| 57 |
-
cursor: pointer;
|
| 58 |
}
|
| 59 |
-
|
| 60 |
-
|
| 61 |
}
|
| 62 |
</style>
|
| 63 |
</head>
|
| 64 |
<body>
|
| 65 |
-
<
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
<button onclick="cleanup()">Cleanup</button>
|
| 71 |
-
</div>
|
| 72 |
</div>
|
| 73 |
-
<
|
| 74 |
-
function executeCode() {
|
| 75 |
-
const codeInput = document.getElementById("code-input");
|
| 76 |
-
const outputDiv = document.getElementById("output");
|
| 77 |
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
})
|
| 85 |
-
.then(response => {
|
| 86 |
-
const reader = response.body.getReader();
|
| 87 |
-
const decoder = new TextDecoder();
|
| 88 |
-
let content = "";
|
| 89 |
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
content += decoder.decode(value);
|
| 94 |
-
outputDiv.innerHTML += content;
|
| 95 |
-
outputDiv.scrollTop = outputDiv.scrollHeight;
|
| 96 |
-
readStream();
|
| 97 |
-
});
|
| 98 |
-
}
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
.catch(error => {
|
| 103 |
-
outputDiv.innerHTML += `<br>Error: ${error}`;
|
| 104 |
-
outputDiv.scrollTop = outputDiv.scrollHeight;
|
| 105 |
-
});
|
| 106 |
-
codeInput.value = "";
|
| 107 |
-
}
|
| 108 |
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
outputDiv.innerHTML += `\n${data.result}`;
|
| 115 |
-
outputDiv.scrollTop = outputDiv.scrollHeight;
|
| 116 |
});
|
| 117 |
-
|
| 118 |
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
</script>
|
| 121 |
</body>
|
| 122 |
-
</html>
|
|
|
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
|
|
|
| 7 |
<style>
|
| 8 |
body {
|
| 9 |
font-family: Arial, sans-serif;
|
| 10 |
+
margin: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
}
|
| 12 |
+
#terminal {
|
| 13 |
+
width: 100%;
|
| 14 |
+
height: 300px;
|
| 15 |
+
background: #000;
|
| 16 |
+
color: #0f0;
|
| 17 |
+
overflow-y: auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
padding: 10px;
|
| 19 |
border-radius: 5px;
|
|
|
|
|
|
|
|
|
|
| 20 |
}
|
| 21 |
+
#input-area {
|
| 22 |
display: flex;
|
| 23 |
+
margin-top: 10px;
|
| 24 |
}
|
| 25 |
+
#command-input {
|
| 26 |
flex: 1;
|
| 27 |
padding: 10px;
|
| 28 |
+
font-size: 16px;
|
|
|
|
|
|
|
|
|
|
| 29 |
}
|
| 30 |
button {
|
| 31 |
+
padding: 10px 15px;
|
| 32 |
+
font-size: 16px;
|
| 33 |
+
margin-left: 5px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
| 35 |
+
.audio-link {
|
| 36 |
+
margin-top: 10px;
|
| 37 |
}
|
| 38 |
</style>
|
| 39 |
</head>
|
| 40 |
<body>
|
| 41 |
+
<h1>Python Terminal</h1>
|
| 42 |
+
<div id="terminal"></div>
|
| 43 |
+
<div id="input-area">
|
| 44 |
+
<input type="text" id="command-input" placeholder="Enter Python or shell command">
|
| 45 |
+
<button onclick="runCommand()">Run</button>
|
|
|
|
|
|
|
| 46 |
</div>
|
| 47 |
+
<div id="audio-container"></div>
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
<script>
|
| 50 |
+
const terminal = document.getElementById("terminal");
|
| 51 |
+
const commandInput = document.getElementById("command-input");
|
| 52 |
+
const audioContainer = document.getElementById("audio-container");
|
| 53 |
|
| 54 |
+
function appendToTerminal(text) {
|
| 55 |
+
terminal.innerHTML += text + "<br>";
|
| 56 |
+
terminal.scrollTop = terminal.scrollHeight;
|
| 57 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
async function runCommand() {
|
| 60 |
+
const command = commandInput.value;
|
| 61 |
+
if (!command.trim()) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
+
appendToTerminal("> " + command);
|
| 64 |
+
commandInput.value = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
+
try {
|
| 67 |
+
const response = await fetch("/run", {
|
| 68 |
+
method: "POST",
|
| 69 |
+
headers: { "Content-Type": "application/json" },
|
| 70 |
+
body: JSON.stringify({ command }),
|
|
|
|
|
|
|
| 71 |
});
|
| 72 |
+
const result = await response.json();
|
| 73 |
|
| 74 |
+
if (result.output) appendToTerminal(result.output);
|
| 75 |
+
if (result.error) appendToTerminal("<span style='color:red'>" + result.error + "</span>");
|
| 76 |
+
if (result.audio_file) {
|
| 77 |
+
const audioLink = `<a href="/download/${result.audio_file}" target="_blank" class="audio-link">Download/Play Audio</a>`;
|
| 78 |
+
audioContainer.innerHTML = audioLink;
|
| 79 |
+
}
|
| 80 |
+
} catch (error) {
|
| 81 |
+
appendToTerminal("<span style='color:red'>Error: " + error.message + "</span>");
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
</script>
|
| 85 |
</body>
|
| 86 |
+
</html>
|