Update app.py
Browse files
app.py
CHANGED
|
@@ -47,7 +47,7 @@ def login(id, pw):
|
|
| 47 |
if user_data[id] != pw:
|
| 48 |
return "fail"
|
| 49 |
else:
|
| 50 |
-
live_user[id] =
|
| 51 |
return "ok"
|
| 52 |
|
| 53 |
def chat(name, text, time):
|
|
@@ -55,18 +55,16 @@ def chat(name, text, time):
|
|
| 55 |
return "no id"
|
| 56 |
else:
|
| 57 |
chat_history.append({"name": name, "text":text, "time":time})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
return "ok"
|
| 59 |
|
| 60 |
-
def get_data(name):
|
| 61 |
-
global live_user
|
| 62 |
-
for u in live_user.keys():
|
| 63 |
-
if u == name:
|
| 64 |
-
live_user[u] = 50
|
| 65 |
-
else:
|
| 66 |
-
live_user[u] -= 1
|
| 67 |
-
if live_user[u] < 0:
|
| 68 |
-
del live_user[u]
|
| 69 |
-
return chat_history
|
| 70 |
|
| 71 |
def get_live_user():
|
| 72 |
return live_user.keys()
|
|
@@ -79,6 +77,9 @@ def clear_data():
|
|
| 79 |
|
| 80 |
with gr.Blocks() as demo:
|
| 81 |
count = 0
|
|
|
|
|
|
|
|
|
|
| 82 |
aa = gr.Interface(
|
| 83 |
fn=chat,
|
| 84 |
inputs=["text", "text", "text"],
|
|
@@ -97,12 +98,6 @@ with gr.Blocks() as demo:
|
|
| 97 |
outputs="text",
|
| 98 |
description="register",
|
| 99 |
)
|
| 100 |
-
dd = gr.Interface(
|
| 101 |
-
fn=get_data,
|
| 102 |
-
inputs=["text"],
|
| 103 |
-
outputs="text",
|
| 104 |
-
description="get_data",
|
| 105 |
-
)
|
| 106 |
gg = gr.Interface(
|
| 107 |
fn=get_live_user,
|
| 108 |
inputs=[],
|
|
|
|
| 47 |
if user_data[id] != pw:
|
| 48 |
return "fail"
|
| 49 |
else:
|
| 50 |
+
live_user[id] = 20
|
| 51 |
return "ok"
|
| 52 |
|
| 53 |
def chat(name, text, time):
|
|
|
|
| 55 |
return "no id"
|
| 56 |
else:
|
| 57 |
chat_history.append({"name": name, "text":text, "time":time})
|
| 58 |
+
global live_user
|
| 59 |
+
for u in live_user.keys():
|
| 60 |
+
if u == name:
|
| 61 |
+
live_user[u] = 20
|
| 62 |
+
else:
|
| 63 |
+
live_user[u] -= 1
|
| 64 |
+
if live_user[u] < 0:
|
| 65 |
+
del live_user[u]
|
| 66 |
return "ok"
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
def get_live_user():
|
| 70 |
return live_user.keys()
|
|
|
|
| 77 |
|
| 78 |
with gr.Blocks() as demo:
|
| 79 |
count = 0
|
| 80 |
+
def echo(text, request: gr.Request):
|
| 81 |
+
return chat_history
|
| 82 |
+
io = gr.Interface(echo, "textbox", "textbox")
|
| 83 |
aa = gr.Interface(
|
| 84 |
fn=chat,
|
| 85 |
inputs=["text", "text", "text"],
|
|
|
|
| 98 |
outputs="text",
|
| 99 |
description="register",
|
| 100 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
gg = gr.Interface(
|
| 102 |
fn=get_live_user,
|
| 103 |
inputs=[],
|