Empereur-Pirate commited on
Commit
141e519
·
verified ·
1 Parent(s): 8db8221

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +5 -5
static/script.js CHANGED
@@ -1,4 +1,3 @@
1
- // Remove the hidden class
2
  function revealContent() {
3
  const loader = document.getElementById('loader');
4
  const textGenContainer = document.getElementById('text-gen-container');
@@ -12,7 +11,7 @@ document.addEventListener('DOMContentLoaded', () => {
12
  const initConnection = async () => {
13
  try {
14
  // Fetch the endpoint
15
- const connectionResult = await fetch('/infer_t5');
16
 
17
  // Parse the JSON response
18
  if (!connectionResult.ok) {
@@ -48,10 +47,11 @@ document.addEventListener('DOMContentLoaded', () => {
48
  // Attempt to connect to the endpoint
49
  initConnection();
50
  });
 
51
  const textGenForm = document.querySelector(".text-gen-form");
52
 
53
- const translateText = async (text) => {
54
- const inferResponse = await fetch(`/infer_t5?input=${encodeURIComponent(text)}`);
55
  const inferJson = await inferResponse.json();
56
 
57
  return inferJson.output;
@@ -63,5 +63,5 @@ textGenForm.addEventListener("submit", async (event) => {
63
  const textGenInput = document.getElementById("text-gen-input");
64
  const textGenParagraph = document.querySelector(".text-gen-output");
65
 
66
- textGenParagraph.textContent = await translateText(textGenInput.value);
67
  });
 
 
1
  function revealContent() {
2
  const loader = document.getElementById('loader');
3
  const textGenContainer = document.getElementById('text-gen-container');
 
11
  const initConnection = async () => {
12
  try {
13
  // Fetch the endpoint
14
+ const connectionResult = await fetch('/generate_text');
15
 
16
  // Parse the JSON response
17
  if (!connectionResult.ok) {
 
47
  // Attempt to connect to the endpoint
48
  initConnection();
49
  });
50
+
51
  const textGenForm = document.querySelector(".text-gen-form");
52
 
53
+ const generateText = async (text) => {
54
+ const inferResponse = await fetch(`/generate_text?input=${encodeURIComponent(text)}`);
55
  const inferJson = await inferResponse.json();
56
 
57
  return inferJson.output;
 
63
  const textGenInput = document.getElementById("text-gen-input");
64
  const textGenParagraph = document.querySelector(".text-gen-output");
65
 
66
+ textGenParagraph.textContent = await generateText(textGenInput.value);
67
  });