diff --git a/server.py b/server.py index b09bb6c..e50b72c 100755 --- a/server.py +++ b/server.py @@ -43,7 +43,7 @@ new_button = """ > -
+
+
+ +""" +reset_form = """ + +
+ +
""" # Constants REDIS_MESSAGE_LIST = "chat_messages" @@ -187,10 +215,20 @@ async def websocket_endpoint(websocket: WebSocket): # Publish message to Redis await redis_client.publish(WEBSOCKET_CHANNEL, data_str) + await websocket.send_text(reset_form) except WebSocketDisconnect: connected_clients.pop(name) +@app.get("/clear-chat") +async def clear_chat(): + await redis_client.delete(REDIS_MESSAGE_LIST) + return """ +
+
+ """ + + @app.get("/") async def root(request: Request): return templates.TemplateResponse("index.html", {"request": request}) diff --git a/templates/index.html b/templates/index.html index 813a65b..7eaffa3 100644 --- a/templates/index.html +++ b/templates/index.html @@ -33,8 +33,17 @@
-
- + +