Spaces:
Runtime error
Runtime error
File size: 1,079 Bytes
68af58f 9409415 68af58f 9409415 68af58f 9409415 68af58f 9409415 68af58f f19a96c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
from datetime import datetime
chatrooms = {}
def chatroom(username, message, send_message, chatroom_name):
if chatroom_name not in chatrooms:
chatrooms[chatroom_name] = []
if send_message:
now = datetime.now()
timestamp = now.strftime("%Y-%m-%d %H:%M:%S")
chatrooms[chatroom_name].append((username, message, timestamp))
message_history = "<br>".join([f"{msg[2]} {msg[0]}: {msg[1]}" for msg in chatrooms[chatroom_name]])
return message_history, ""
iface = gr.Interface(fn=chatroom,
inputs=[gr.inputs.Textbox("Username"),
gr.inputs.Textbox("Message"),
gr.inputs.Checkbox("Send"),
gr.inputs.Textbox(label="Quiz Name")],
outputs=["html", "text"],
layout="vertical",
title="Quiz to join!",
description="Type your username and message, and click Send to send to the quiz name specified in: Quiz Name.")
iface.launch() |