extra / static /script.js
qianmuuq's picture
Update static/script.js
9b43175
raw
history blame
671 Bytes
const textGenForm = document.querySelector('.text-gen-form');
const translateText = async (text) => {
const inferResponse = await fetch(`infer_t5?input=${text}`);
const inferJson = await inferResponse.json();
return inferJson.output;
};
textGenForm.addEventListener('submit', async (event) => {
event.preventDefault();
const textGenInput = document.getElementById('text-gen-input');
const textGenParagraph = document.querySelector('.text-gen-output');
try {
var text_out = await translateText(textGenInput.value);
text_out = text_out+"\n"+"s";
textGenParagraph.textContent = text_out;
} catch (err) {
console.error(err);
}
});