ldhldh commited on
Commit
c2bc0a6
1 Parent(s): dd9b8ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -76
app.py CHANGED
@@ -28,94 +28,22 @@ def get_types(cls_set: List[Type], component: str):
28
  return docset, types
29
  routes.get_types = get_types
30
 
31
- user_data = dict()
32
- live_user = dict()
33
- chat_history = []
34
-
35
-
36
- def register(id, pw):
37
  if not id in user_data:
38
  user_data[id] = pw
39
  return "ok"
40
  else:
41
  return "fail"
42
 
43
- def login(id, pw):
44
- if not id in user_data:
45
- return "fail"
46
- else:
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):
54
- if not name in user_data:
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] = 20
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()
73
-
74
- def clear_data():
75
- global chat_history
76
- chat_history = []
77
- return "ok"
78
-
79
-
80
  with gr.Blocks() as demo:
81
  count = 0
82
  gr.Markdown(
83
- f"{chat_history}"
84
  )
85
  aa = gr.Interface(
86
- fn=chat,
87
- inputs=["text", "text", "text"],
88
- outputs="text",
89
- description="chat",
90
- )
91
- bb = gr.Interface(
92
- fn=login,
93
- inputs=["text", "text"],
94
- outputs="text",
95
- description="login",
96
- )
97
- cc = gr.Interface(
98
- fn=register,
99
  inputs=["text", "text"],
100
  outputs="text",
101
- description="register",
102
- )
103
- dd = gr.Interface(
104
- fn=get_data,
105
- inputs=["text"],
106
- outputs="text",
107
- description="get_data",
108
- )
109
- gg = gr.Interface(
110
- fn=get_live_user,
111
- inputs=[],
112
- outputs="text",
113
- description="get_live_user",
114
- )
115
- ss = gr.Interface(
116
- fn=clear_data,
117
- inputs=[],
118
- outputs="text",
119
- description="clear_data",
120
  )
121
  demo.queue(max_size=32).launch()
 
28
  return docset, types
29
  routes.get_types = get_types
30
 
31
+ def example_func(id, pw):
 
 
 
 
 
32
  if not id in user_data:
33
  user_data[id] = pw
34
  return "ok"
35
  else:
36
  return "fail"
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  with gr.Blocks() as demo:
39
  count = 0
40
  gr.Markdown(
41
+ f"sample app"
42
  )
43
  aa = gr.Interface(
44
+ fn=example_func,
 
 
 
 
 
 
 
 
 
 
 
 
45
  inputs=["text", "text"],
46
  outputs="text",
47
+ description="example_func",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  )
49
  demo.queue(max_size=32).launch()