Update templates/index.html
Browse files- templates/index.html +16 -54
templates/index.html
CHANGED
|
@@ -5,67 +5,16 @@
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Python Terminal</title>
|
| 7 |
<style>
|
| 8 |
-
|
| 9 |
-
font-family: Arial, sans-serif;
|
| 10 |
-
background-color: #1e1e1e;
|
| 11 |
-
color: #c7c7c7;
|
| 12 |
-
margin: 0;
|
| 13 |
-
padding: 0;
|
| 14 |
-
display: flex;
|
| 15 |
-
justify-content: center;
|
| 16 |
-
align-items: center;
|
| 17 |
-
height: 100vh;
|
| 18 |
-
}
|
| 19 |
-
.terminal {
|
| 20 |
-
width: 80%;
|
| 21 |
-
height: 70%;
|
| 22 |
-
background: #2e2e2e;
|
| 23 |
-
border-radius: 8px;
|
| 24 |
-
padding: 15px;
|
| 25 |
-
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
|
| 26 |
-
display: flex;
|
| 27 |
-
flex-direction: column;
|
| 28 |
-
}
|
| 29 |
-
.terminal-output {
|
| 30 |
-
flex: 1;
|
| 31 |
-
background: #1e1e1e;
|
| 32 |
-
padding: 10px;
|
| 33 |
-
border-radius: 5px;
|
| 34 |
-
overflow-y: auto;
|
| 35 |
-
margin-bottom: 10px;
|
| 36 |
-
white-space: pre-wrap;
|
| 37 |
-
}
|
| 38 |
-
.terminal-input {
|
| 39 |
-
display: flex;
|
| 40 |
-
}
|
| 41 |
-
input {
|
| 42 |
-
flex: 1;
|
| 43 |
-
padding: 10px;
|
| 44 |
-
border-radius: 5px;
|
| 45 |
-
border: 1px solid #444;
|
| 46 |
-
background: #1e1e1e;
|
| 47 |
-
color: #c7c7c7;
|
| 48 |
-
}
|
| 49 |
-
button {
|
| 50 |
-
margin-left: 10px;
|
| 51 |
-
padding: 10px 20px;
|
| 52 |
-
border: none;
|
| 53 |
-
border-radius: 5px;
|
| 54 |
-
background: #0078d4;
|
| 55 |
-
color: white;
|
| 56 |
-
cursor: pointer;
|
| 57 |
-
}
|
| 58 |
-
button:hover {
|
| 59 |
-
background: #005bb5;
|
| 60 |
-
}
|
| 61 |
</style>
|
| 62 |
</head>
|
| 63 |
<body>
|
| 64 |
<div class="terminal">
|
| 65 |
<div id="output" class="terminal-output">Python Terminal Ready...</div>
|
| 66 |
<div class="terminal-input">
|
| 67 |
-
<input type="text" id="code-input" placeholder="Enter Python code
|
| 68 |
<button onclick="executeCode()">Run</button>
|
|
|
|
| 69 |
</div>
|
| 70 |
</div>
|
| 71 |
<script>
|
|
@@ -89,6 +38,19 @@
|
|
| 89 |
outputDiv.scrollTop = outputDiv.scrollHeight;
|
| 90 |
});
|
| 91 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
</script>
|
| 93 |
</body>
|
| 94 |
</html>
|
|
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Python Terminal</title>
|
| 7 |
<style>
|
| 8 |
+
/* Add terminal styling here */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
</style>
|
| 10 |
</head>
|
| 11 |
<body>
|
| 12 |
<div class="terminal">
|
| 13 |
<div id="output" class="terminal-output">Python Terminal Ready...</div>
|
| 14 |
<div class="terminal-input">
|
| 15 |
+
<input type="text" id="code-input" placeholder="Enter Python code or !pip install package..." />
|
| 16 |
<button onclick="executeCode()">Run</button>
|
| 17 |
+
<button onclick="cleanup()">Cleanup</button>
|
| 18 |
</div>
|
| 19 |
</div>
|
| 20 |
<script>
|
|
|
|
| 38 |
outputDiv.scrollTop = outputDiv.scrollHeight;
|
| 39 |
});
|
| 40 |
}
|
| 41 |
+
|
| 42 |
+
function cleanup() {
|
| 43 |
+
fetch("/cleanup", { method: "POST" })
|
| 44 |
+
.then(response => response.json())
|
| 45 |
+
.then(data => {
|
| 46 |
+
const outputDiv = document.getElementById("output");
|
| 47 |
+
outputDiv.innerHTML += `\n${data.result}`;
|
| 48 |
+
outputDiv.scrollTop = outputDiv.scrollHeight; // Auto-scroll to bottom
|
| 49 |
+
});
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
// Cleanup temporary files when the user leaves the page
|
| 53 |
+
window.addEventListener("beforeunload", cleanup);
|
| 54 |
</script>
|
| 55 |
</body>
|
| 56 |
</html>
|