Download static/script.js from Artificial-superintelligence/Athspi: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/Artificial-superintelligence/Athspi/resolve/main/static/script.js
- Command line
-
hf download hf://spaces/Artificial-superintelligence/Athspi/static/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Artificial-superintelligence/Athspi/resolve/main/static/script.js
1.45 kB
| document.getElementById("user-input").addEventListener("keydown", function(event) { | |
| if (event.key === "Enter") { | |
| let userInput = this.value.trim(); | |
| if (userInput) { | |
| addOutput(userInput); | |
| this.value = ""; // Clear input field | |
| // Send the user input to the backend for execution | |
| executePythonCode(userInput); | |
| } | |
| } | |
| }); | |
| function addOutput(text) { | |
| const outputDiv = document.createElement("div"); | |
| outputDiv.classList.add("prompt"); | |
| outputDiv.textContent = `>>> ${text}`; | |
| document.querySelector(".output").appendChild(outputDiv); | |
| } | |
| function executePythonCode(code) { | |
| // Sending code to Flask backend | |
| fetch('/execute', { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| body: JSON.stringify({ code: code }), | |
| }) | |
| .then(response => response.json()) | |
| .then(data => { | |
| addExecutionResult(data.result); | |
| }) | |
| .catch(error => { | |
| addExecutionResult("Error: " + error); | |
| }); | |
| } | |
| function addExecutionResult(result) { | |
| const outputDiv = document.createElement("div"); | |
| outputDiv.classList.add("output"); | |
| outputDiv.textContent = result; | |
| document.querySelector(".output").appendChild(outputDiv); | |
| scrollToBottom(); | |
| } | |
| function scrollToBottom() { | |
| const terminal = document.getElementById("terminal"); | |
| terminal.scrollTop = terminal.scrollHeight; | |
| } | |