Spaces:
Paused
Paused
Commit
·
9486abb
1
Parent(s):
6b6784f
Update main.py
Browse files
main.py
CHANGED
@@ -29,7 +29,8 @@ HTML = """
|
|
29 |
const prompt = document.getElementById("prompt");
|
30 |
const output = document.getElementById("output");
|
31 |
|
32 |
-
|
|
|
33 |
ws.onmessage = (e) => answer(e.data);
|
34 |
|
35 |
function ask(event) {
|
@@ -64,4 +65,19 @@ async def answer(ws: WebSocket):
|
|
64 |
async for el in output:
|
65 |
await ws.send_text(el)
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
await ws.close()
|
|
|
29 |
const prompt = document.getElementById("prompt");
|
30 |
const output = document.getElementById("output");
|
31 |
|
32 |
+
// TODO!
|
33 |
+
const ws = new WebSocket("wss://daniilalpha-answerer-api.hf.space/answer_test");
|
34 |
ws.onmessage = (e) => answer(e.data);
|
35 |
|
36 |
function ask(event) {
|
|
|
65 |
async for el in output:
|
66 |
await ws.send_text(el)
|
67 |
|
68 |
+
await ws.close()
|
69 |
+
|
70 |
+
async def answerer_test():
|
71 |
+
for i in range(10000):
|
72 |
+
yield i
|
73 |
+
|
74 |
+
@app.websocket("/answer_test")
|
75 |
+
async def answer(ws: WebSocket):
|
76 |
+
await ws.accept()
|
77 |
+
|
78 |
+
input = await ws.receive_text()
|
79 |
+
output = answerer_test()
|
80 |
+
async for el in output:
|
81 |
+
await ws.send_text(el)
|
82 |
+
|
83 |
await ws.close()
|