bedrock123 commited on
Commit
68af58f
·
1 Parent(s): c4df769

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from datetime import datetime
3
+
4
+ quizes = {}
5
+
6
+ def quiz(username, message, send_message, chatroom_name):
7
+ if chatroom_name not in chatrooms:
8
+ chatrooms[chatroom_name] = []
9
+ if send_message:
10
+ now = datetime.now()
11
+ timestamp = now.strftime("%Y-%m-%d %H:%M:%S")
12
+ chatrooms[chatroom_name].append((username, message, timestamp))
13
+ message_history = "<br>".join([f"{msg[2]} {msg[0]}: {msg[1]}" for msg in chatrooms[chatroom_name]])
14
+ return message_history, ""
15
+
16
+ iface = gr.Interface(fn=quiz,
17
+ inputs=[gr.inputs.Textbox("Username"),
18
+ gr.inputs.Textbox("Message"),
19
+ gr.inputs.Checkbox("Send"),
20
+ gr.inputs.Textbox(label="Quiz Name")],
21
+ outputs=["html", "text"],
22
+ layout="vertical",
23
+ title="Quiz to join!",
24
+ description="Type your username and message, and click Send to send to the quiz name specified in: Quiz Name.")
25
+
26
+ iface.launch(share=True)