Artificial-superintelligence commited on
Commit
bb3c1b4
·
verified ·
1 Parent(s): a15e38b

Update templates/index.html

Browse files
Files changed (1) hide show
  1. 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
- 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>
 
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">&gt;</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>