Spaces:
Paused
Paused
Commit
·
a05f54e
1
Parent(s):
bd21e60
Update main.py
Browse files
main.py
CHANGED
|
@@ -25,15 +25,16 @@ HTML = """
|
|
| 25 |
<input type="submit" value="SEND" />
|
| 26 |
</form>
|
| 27 |
|
| 28 |
-
<p id="output"
|
| 29 |
<script>
|
| 30 |
const prompt = document.getElementById("prompt");
|
| 31 |
const output = document.getElementById("output");
|
| 32 |
|
| 33 |
const ws = new WebSocket("wss://huggingface.co/spaces/DaniilAlpha/answerer-api:8000/answer");
|
| 34 |
-
ws.
|
| 35 |
-
|
| 36 |
-
}
|
|
|
|
| 37 |
|
| 38 |
function ask(event) {
|
| 39 |
ws.send(prompt.value);
|
|
|
|
| 25 |
<input type="submit" value="SEND" />
|
| 26 |
</form>
|
| 27 |
|
| 28 |
+
<p id="output"></p>
|
| 29 |
<script>
|
| 30 |
const prompt = document.getElementById("prompt");
|
| 31 |
const output = document.getElementById("output");
|
| 32 |
|
| 33 |
const ws = new WebSocket("wss://huggingface.co/spaces/DaniilAlpha/answerer-api:8000/answer");
|
| 34 |
+
ws.onopen = () => console.log("socket open!");
|
| 35 |
+
ws.onclose = () => console.log("socket closed!");
|
| 36 |
+
ws.onerror = (e) => console.error(`error: ${e}`);
|
| 37 |
+
ws.onmessage = (event) => output.innerText = event.data;
|
| 38 |
|
| 39 |
function ask(event) {
|
| 40 |
ws.send(prompt.value);
|