Update app.py
Browse files
app.py
CHANGED
@@ -29,6 +29,7 @@ def get_types(cls_set: List[Type], component: str):
|
|
29 |
routes.get_types = get_types
|
30 |
|
31 |
user_data = dict()
|
|
|
32 |
chat_history = []
|
33 |
|
34 |
|
@@ -46,6 +47,7 @@ def login(id, pw):
|
|
46 |
if user_data[id] != pw:
|
47 |
return "fail"
|
48 |
else:
|
|
|
49 |
return "ok"
|
50 |
|
51 |
def chat(name, text):
|
@@ -55,14 +57,25 @@ def chat(name, text):
|
|
55 |
chat_history.append({"name": name, "text":text})
|
56 |
return "ok"
|
57 |
|
58 |
-
def get_data():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
return chat_history
|
60 |
|
|
|
|
|
|
|
61 |
def clear_data():
|
62 |
global chat_history
|
63 |
chat_history = []
|
64 |
return "ok"
|
65 |
|
|
|
66 |
with gr.Blocks() as demo:
|
67 |
count = 0
|
68 |
aa = gr.Interface(
|
@@ -85,11 +98,17 @@ with gr.Blocks() as demo:
|
|
85 |
)
|
86 |
dd = gr.Interface(
|
87 |
fn=get_data,
|
88 |
-
inputs=[],
|
89 |
outputs="text",
|
90 |
description="get_data",
|
91 |
)
|
92 |
gg = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
fn=clear_data,
|
94 |
inputs=[],
|
95 |
outputs="text",
|
|
|
29 |
routes.get_types = get_types
|
30 |
|
31 |
user_data = dict()
|
32 |
+
live_user = dict()
|
33 |
chat_history = []
|
34 |
|
35 |
|
|
|
47 |
if user_data[id] != pw:
|
48 |
return "fail"
|
49 |
else:
|
50 |
+
live_user[id] = 100
|
51 |
return "ok"
|
52 |
|
53 |
def chat(name, text):
|
|
|
57 |
chat_history.append({"name": name, "text":text})
|
58 |
return "ok"
|
59 |
|
60 |
+
def get_data(name):
|
61 |
+
for u in live_user.keys():
|
62 |
+
if u == name:
|
63 |
+
live_user[u] += 20
|
64 |
+
else:
|
65 |
+
live_user[u] -= 1
|
66 |
+
if live_user[u] < 0:
|
67 |
+
del live_user[u]
|
68 |
return chat_history
|
69 |
|
70 |
+
def get_live_user():
|
71 |
+
return live_user
|
72 |
+
|
73 |
def clear_data():
|
74 |
global chat_history
|
75 |
chat_history = []
|
76 |
return "ok"
|
77 |
|
78 |
+
|
79 |
with gr.Blocks() as demo:
|
80 |
count = 0
|
81 |
aa = gr.Interface(
|
|
|
98 |
)
|
99 |
dd = gr.Interface(
|
100 |
fn=get_data,
|
101 |
+
inputs=["text"],
|
102 |
outputs="text",
|
103 |
description="get_data",
|
104 |
)
|
105 |
gg = gr.Interface(
|
106 |
+
fn=get_live_user,
|
107 |
+
inputs=[],
|
108 |
+
outputs="text",
|
109 |
+
description="get_live_user",
|
110 |
+
)
|
111 |
+
ss = gr.Interface(
|
112 |
fn=clear_data,
|
113 |
inputs=[],
|
114 |
outputs="text",
|