Update app.py
Browse files27 unmodified lines28293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012127 unmodified linesreturn docset, typesroutes.get_types = get_typesuser_data = dict()live_user = dict()chat_history = []def register(id, pw):if not id in user_data:user_data[id] = pwreturn "ok"else:return "fail"def login(id, pw):if not id in user_data:return "fail"else:if user_data[id] != pw:return "fail"else:live_user[id] = 20return "ok"def chat(name, text, time):if not name in user_data:return "no id"else:chat_history.append({"name": name, "text":text, "time":time})return "ok"def get_data(name):global live_userfor u in live_user.keys():if u == name:live_user[u] = 20else:live_user[u] -= 1if live_user[u] < 0:del live_user[u]return chat_historydef get_live_user():return live_user.keys()def clear_data():global chat_historychat_history = []return "ok"with gr.Blocks() as demo:count = 0gr.Markdown(f"{chat_history}")aa = gr.Interface(fn=chat,inputs=["text", "text", "text"],outputs="text",description="chat",)bb = gr.Interface(fn=login,inputs=["text", "text"],outputs="text",description="login",)cc = gr.Interface(fn=register,inputs=["text", "text"],outputs="text",description="register",)dd = gr.Interface(fn=get_data,inputs=["text"],outputs="text",description="get_data",)gg = gr.Interface(fn=get_live_user,inputs=[],outputs="text",description="get_live_user",)ss = gr.Interface(fn=clear_data,inputs=[],outputs="text",description="clear_data",)demo.queue(max_size=32).launch()27 unmodified lines2829303132333435363738394041424344454647484927 unmodified linesreturn docset, typesroutes.get_types = get_typesdef example_func(id, pw):if not id in user_data:user_data[id] = pwreturn "ok"else:return "fail"with gr.Blocks() as demo:count = 0gr.Markdown(f"sample app")aa = gr.Interface(fn=example_func,inputs=["text", "text"],outputs="text",description="example_func",)demo.queue(max_size=32).launch()
app.py+4-76