Spaces:
Sleeping
Sleeping
Update templates/write.html
Browse files- templates/write.html +7 -3
templates/write.html
CHANGED
|
@@ -86,8 +86,8 @@
|
|
| 86 |
const word_limit = document.getElementById("word-limit").value;
|
| 87 |
const type = document.getElementById("type").value;
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
| 91 |
method: "POST",
|
| 92 |
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
| 93 |
body: new URLSearchParams({ question: userInput, word_limit: word_limit, type: type })
|
|
@@ -101,7 +101,11 @@
|
|
| 101 |
answer_area.value = data.answer; // set textarea value
|
| 102 |
} else if (data.error) {
|
| 103 |
answer_area.value = "Error: " + data.error;
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
}
|
| 106 |
|
| 107 |
</script>
|
|
|
|
| 86 |
const word_limit = document.getElementById("word-limit").value;
|
| 87 |
const type = document.getElementById("type").value;
|
| 88 |
|
| 89 |
+
try {
|
| 90 |
+
const response = await fetch("http://localhost:5003/ask", {
|
| 91 |
method: "POST",
|
| 92 |
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
| 93 |
body: new URLSearchParams({ question: userInput, word_limit: word_limit, type: type })
|
|
|
|
| 101 |
answer_area.value = data.answer; // set textarea value
|
| 102 |
} else if (data.error) {
|
| 103 |
answer_area.value = "Error: " + data.error;
|
| 104 |
+
}
|
| 105 |
+
} catch (error) {
|
| 106 |
+
answer_area.value = error
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
}
|
| 110 |
|
| 111 |
</script>
|