Spaces:
Runtime error
Runtime error
Download script.js from Noveramaaz/Text-translator: direct link, hf CLI and curl.
- Browser
- Download file 878 Bytes
-
https://huggingface.co/spaces/Noveramaaz/Text-translator/resolve/main/script.js
- Command line
-
hf download hf://spaces/Noveramaaz/Text-translator/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Noveramaaz/Text-translator/resolve/main/script.js
878 Bytes
| document.getElementById("translate-button").addEventListener("click", function() { | |
| var text = document.getElementById("text-input").value; | |
| var targetLanguage = document.getElementById("language-select").value; | |
| translateText(text, targetLanguage); | |
| }); | |
| function translateText(text, targetLanguage) { | |
| // You can use fetch or any other method to send the text to your Python backend for translation | |
| fetch('/translate', { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| body: JSON.stringify({ | |
| text: text, | |
| target_language: targetLanguage | |
| }) | |
| }) | |
| .then(response => response.json()) | |
| .then(data => { | |
| document.getElementById("translated-text").value = data.translated_text; | |
| }) | |
| .catch((error) => { | |
| console.error('Error:', error); | |
| }); | |
| } | |