Spaces:
Paused
Paused
Commit
·
ef88068
1
Parent(s):
746b450
updates html
Browse files- static/index.html +9 -7
static/index.html
CHANGED
|
@@ -73,15 +73,17 @@
|
|
| 73 |
headers: { 'Content-Type': 'application/json' },
|
| 74 |
body: JSON.stringify({ message: msg, gender })
|
| 75 |
});
|
| 76 |
-
const data = await res.json();
|
| 77 |
|
| 78 |
-
if (res.ok) {
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
} else {
|
| 83 |
-
replyText.textContent = 'Error: ' + (data.error || res.statusText);
|
| 84 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
} catch (err) {
|
| 86 |
replyText.textContent = 'Fetch error: ' + err.message;
|
| 87 |
}
|
|
|
|
| 73 |
headers: { 'Content-Type': 'application/json' },
|
| 74 |
body: JSON.stringify({ message: msg, gender })
|
| 75 |
});
|
|
|
|
| 76 |
|
| 77 |
+
if (!res.ok) {
|
| 78 |
+
const errorText = await res.text();
|
| 79 |
+
replyText.textContent = 'Error: ' + errorText;
|
| 80 |
+
return;
|
|
|
|
|
|
|
| 81 |
}
|
| 82 |
+
|
| 83 |
+
const data = await res.json();
|
| 84 |
+
replyText.textContent = data.response;
|
| 85 |
+
replyAudio.src = '/static/' + data.audiofile;
|
| 86 |
+
replyAudio.hidden = false;
|
| 87 |
} catch (err) {
|
| 88 |
replyText.textContent = 'Fetch error: ' + err.message;
|
| 89 |
}
|