DaniilAlpha commited on
Commit
a05f54e
·
1 Parent(s): bd21e60

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +5 -4
main.py CHANGED
@@ -25,15 +25,16 @@ HTML = """
25
  <input type="submit" value="SEND" />
26
  </form>
27
 
28
- <p id="output" placeholder="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.onmessage = function (event) {
35
- output.innerText = event.data;
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);