Spaces:
Runtime error
Runtime error
Commit
·
9409415
1
Parent(s):
9c81d2b
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
from datetime import datetime
|
3 |
|
4 |
-
|
5 |
|
6 |
-
def
|
7 |
-
if chatroom_name not in
|
8 |
-
|
9 |
if send_message:
|
10 |
now = datetime.now()
|
11 |
timestamp = now.strftime("%Y-%m-%d %H:%M:%S")
|
12 |
-
|
13 |
-
message_history = "<br>".join([f"{msg[2]} {msg[0]}: {msg[1]}" for msg in
|
14 |
return message_history, ""
|
15 |
|
16 |
-
iface = gr.Interface(fn=
|
17 |
inputs=[gr.inputs.Textbox("Username"),
|
18 |
gr.inputs.Textbox("Message"),
|
19 |
gr.inputs.Checkbox("Send"),
|
|
|
1 |
import gradio as gr
|
2 |
from datetime import datetime
|
3 |
|
4 |
+
chatrooms = {}
|
5 |
|
6 |
+
def chatroom(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=chatroom,
|
17 |
inputs=[gr.inputs.Textbox("Username"),
|
18 |
gr.inputs.Textbox("Message"),
|
19 |
gr.inputs.Checkbox("Send"),
|