Spaces:
Runtime error
Runtime error
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() |