InnoLink commited on
Commit
5deff6d
·
verified ·
1 Parent(s): 03cb9fc

Update static/script.JS

Browse files
Files changed (1) hide show
  1. static/script.JS +23 -0
static/script.JS CHANGED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // initial script
2
+
3
+ const textGenForm = document.querySelector('.text-gen-form');
4
+
5
+ const translateText = async (text) => {
6
+ const inferResponse = await fetch(`infer_t5?input=${text}`);
7
+ const inferJson = await inferResponse.json();
8
+
9
+ return inferJson.output;
10
+ };
11
+
12
+ textGenForm.addEventListener('submit', async (event) => {
13
+ event.preventDefault();
14
+
15
+ const textGenInput = document.getElementById('text-gen-input');
16
+ const textGenParagraph = document.querySelector('.text-gen-output');
17
+
18
+ try {
19
+ textGenParagraph.textContent = await translateText(textGenInput.value);
20
+ } catch (err) {
21
+ console.error(err);
22
+ }
23
+ });