Spaces:
Sleeping
Sleeping
Download static/my_script.js from AppliedInfo/turner_ml: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/AppliedInfo/turner_ml/resolve/main/static/my_script.js
- Command line
-
hf download hf://spaces/AppliedInfo/turner_ml/static/my_script.js
-
curl -L -o my_script.js https://huggingface.co/spaces/AppliedInfo/turner_ml/resolve/main/static/my_script.js
1.08 kB
| const textGenForm = document.querySelector('.text-gen-form'); | |
| const translateText = async (text, rating) => { | |
| const inferResponse = await fetch(`predict`, | |
| {method: "POST", | |
| body: JSON.stringify({text:text, rating:rating}), | |
| headers: {"Content-type": "application/json; charset=UTF-8"}}); | |
| const inferJson = await inferResponse.json(); | |
| const processed_data = inferJson.processed_data | |
| const inferJsonStr = JSON.stringify(processed_data) | |
| return inferJsonStr; | |
| }; | |
| textGenForm.addEventListener('submit', async (event) => { | |
| console.log("inside event listener") | |
| event.preventDefault(); | |
| const textGenInput = document.getElementById('text-gen-input'); | |
| const rating = document.getElementById('rating-input'); | |
| const textGenParagraph = document.querySelector('.text-gen-output'); | |
| try { | |
| const data = await translateText(textGenInput.value, rating.value) | |
| textGenParagraph.textContent = data; | |
| } catch (err) { | |
| console.error(err); | |
| } | |
| }); |