Update templates/index.html
Browse files- templates/index.html +150 -54
templates/index.html
CHANGED
@@ -3,84 +3,180 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>Python Terminal</title>
|
7 |
<style>
|
8 |
-
body {
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
height: 300px;
|
15 |
-
background: #000;
|
16 |
color: #0f0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
overflow-y: auto;
|
|
|
|
|
|
|
|
|
|
|
18 |
padding: 10px;
|
19 |
-
|
20 |
}
|
21 |
-
#
|
|
|
|
|
|
|
|
|
22 |
display: flex;
|
23 |
-
|
|
|
|
|
|
|
24 |
}
|
25 |
-
#
|
26 |
flex: 1;
|
27 |
-
|
|
|
|
|
|
|
28 |
font-size: 16px;
|
|
|
29 |
}
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
}
|
35 |
-
.
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
</style>
|
39 |
</head>
|
40 |
<body>
|
41 |
-
<
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
</div>
|
47 |
-
<div id="audio-container"></div>
|
48 |
-
|
49 |
<script>
|
50 |
-
const
|
51 |
-
const
|
52 |
-
const
|
53 |
|
54 |
-
function
|
55 |
-
|
56 |
-
|
57 |
}
|
58 |
|
59 |
-
|
60 |
-
const command =
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
-
|
64 |
-
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
});
|
72 |
-
|
|
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
83 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
</script>
|
85 |
</body>
|
86 |
-
</html>
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Hacker's Python Terminal</title>
|
7 |
<style>
|
8 |
+
body, html {
|
9 |
+
margin: 0;
|
10 |
+
padding: 0;
|
11 |
+
height: 100%;
|
12 |
+
font-family: 'Courier New', monospace;
|
13 |
+
background-color: #000;
|
|
|
|
|
14 |
color: #0f0;
|
15 |
+
overflow: hidden;
|
16 |
+
}
|
17 |
+
.container {
|
18 |
+
display: flex;
|
19 |
+
height: 100%;
|
20 |
+
}
|
21 |
+
.terminal {
|
22 |
+
flex: 1;
|
23 |
+
padding: 20px;
|
24 |
overflow-y: auto;
|
25 |
+
box-sizing: border-box;
|
26 |
+
}
|
27 |
+
.file-explorer {
|
28 |
+
width: 200px;
|
29 |
+
background-color: #111;
|
30 |
padding: 10px;
|
31 |
+
overflow-y: auto;
|
32 |
}
|
33 |
+
#output {
|
34 |
+
margin-bottom: 20px;
|
35 |
+
white-space: pre-wrap;
|
36 |
+
}
|
37 |
+
#input-line {
|
38 |
display: flex;
|
39 |
+
align-items: center;
|
40 |
+
}
|
41 |
+
#prompt {
|
42 |
+
margin-right: 10px;
|
43 |
}
|
44 |
+
#code-input {
|
45 |
flex: 1;
|
46 |
+
background-color: transparent;
|
47 |
+
border: none;
|
48 |
+
color: #0f0;
|
49 |
+
font-family: 'Courier New', monospace;
|
50 |
font-size: 16px;
|
51 |
+
outline: none;
|
52 |
}
|
53 |
+
.file-item {
|
54 |
+
cursor: pointer;
|
55 |
+
padding: 5px;
|
56 |
+
transition: background-color 0.3s;
|
57 |
}
|
58 |
+
.file-item:hover {
|
59 |
+
background-color: #222;
|
60 |
+
}
|
61 |
+
@keyframes glitch {
|
62 |
+
0% {
|
63 |
+
text-shadow: 0.05em 0 0 #00fffc, -0.05em -0.025em 0 #fc00ff,
|
64 |
+
0.025em 0.05em 0 #fffc00;
|
65 |
+
}
|
66 |
+
14% {
|
67 |
+
text-shadow: 0.05em 0 0 #00fffc, -0.05em -0.025em 0 #fc00ff,
|
68 |
+
0.025em 0.05em 0 #fffc00;
|
69 |
+
}
|
70 |
+
15% {
|
71 |
+
text-shadow: -0.05em -0.025em 0 #00fffc, 0.025em 0.025em 0 #fc00ff,
|
72 |
+
-0.05em -0.05em 0 #fffc00;
|
73 |
+
}
|
74 |
+
49% {
|
75 |
+
text-shadow: -0.05em -0.025em 0 #00fffc, 0.025em 0.025em 0 #fc00ff,
|
76 |
+
-0.05em -0.05em 0 #fffc00;
|
77 |
+
}
|
78 |
+
50% {
|
79 |
+
text-shadow: 0.025em 0.05em 0 #00fffc, 0.05em 0 0 #fc00ff,
|
80 |
+
0 -0.05em 0 #fffc00;
|
81 |
+
}
|
82 |
+
99% {
|
83 |
+
text-shadow: 0.025em 0.05em 0 #00fffc, 0.05em 0 0 #fc00ff,
|
84 |
+
0 -0.05em 0 #fffc00;
|
85 |
+
}
|
86 |
+
100% {
|
87 |
+
text-shadow: -0.025em 0 0 #00fffc, -0.025em -0.025em 0 #fc00ff,
|
88 |
+
-0.025em -0.05em 0 #fffc00;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
.glitch {
|
92 |
+
animation: glitch 1s linear infinite;
|
93 |
}
|
94 |
</style>
|
95 |
</head>
|
96 |
<body>
|
97 |
+
<div class="container">
|
98 |
+
<div class="terminal">
|
99 |
+
<div id="output"></div>
|
100 |
+
<div id="input-line">
|
101 |
+
<span id="prompt" class="glitch">></span>
|
102 |
+
<input type="text" id="code-input" autofocus>
|
103 |
+
</div>
|
104 |
+
</div>
|
105 |
+
<div class="file-explorer">
|
106 |
+
<h3 class="glitch">Files</h3>
|
107 |
+
<div id="file-list"></div>
|
108 |
+
</div>
|
109 |
</div>
|
|
|
|
|
110 |
<script>
|
111 |
+
const outputDiv = document.getElementById('output');
|
112 |
+
const codeInput = document.getElementById('code-input');
|
113 |
+
const fileList = document.getElementById('file-list');
|
114 |
|
115 |
+
function addToOutput(text) {
|
116 |
+
outputDiv.innerHTML += text + '\n';
|
117 |
+
outputDiv.scrollTop = outputDiv.scrollHeight;
|
118 |
}
|
119 |
|
120 |
+
function executeCode() {
|
121 |
+
const command = codeInput.value;
|
122 |
+
addToOutput(`> ${command}`);
|
123 |
+
|
124 |
+
fetch("/execute", {
|
125 |
+
method: "POST",
|
126 |
+
headers: { "Content-Type": "application/json" },
|
127 |
+
body: JSON.stringify({ code: command }),
|
128 |
+
})
|
129 |
+
.then(response => response.json())
|
130 |
+
.then(data => {
|
131 |
+
addToOutput(data.result);
|
132 |
+
updateFileList();
|
133 |
+
})
|
134 |
+
.catch(error => {
|
135 |
+
addToOutput(`Error: ${error}`);
|
136 |
+
});
|
137 |
|
138 |
+
codeInput.value = '';
|
139 |
+
}
|
140 |
|
141 |
+
function updateFileList() {
|
142 |
+
fetch("/list_files")
|
143 |
+
.then(response => response.json())
|
144 |
+
.then(data => {
|
145 |
+
fileList.innerHTML = '';
|
146 |
+
data.files.forEach(file => {
|
147 |
+
const fileItem = document.createElement('div');
|
148 |
+
fileItem.className = 'file-item';
|
149 |
+
fileItem.textContent = file;
|
150 |
+
fileItem.onclick = () => downloadFile(file);
|
151 |
+
fileList.appendChild(fileItem);
|
152 |
});
|
153 |
+
});
|
154 |
+
}
|
155 |
|
156 |
+
function downloadFile(filename) {
|
157 |
+
window.location.href = `/download/${filename}`;
|
158 |
+
}
|
159 |
+
|
160 |
+
function cleanup() {
|
161 |
+
fetch("/cleanup", { method: "POST" })
|
162 |
+
.then(response => response.json())
|
163 |
+
.then(data => {
|
164 |
+
addToOutput(data.result);
|
165 |
+
updateFileList();
|
166 |
+
});
|
167 |
}
|
168 |
+
|
169 |
+
codeInput.addEventListener('keydown', function(event) {
|
170 |
+
if (event.key === 'Enter') {
|
171 |
+
executeCode();
|
172 |
+
}
|
173 |
+
});
|
174 |
+
|
175 |
+
window.addEventListener('load', updateFileList);
|
176 |
+
window.addEventListener('beforeunload', cleanup);
|
177 |
+
|
178 |
+
// Initial message
|
179 |
+
addToOutput("Welcome to the Hacker's Python Terminal. Type your commands below.");
|
180 |
</script>
|
181 |
</body>
|
182 |
+
</html>
|