@@ -32,17 +32,14 @@ async def fetch(self, request):
3232
3333 # Send message history to the newly connected client
3434 if self .message_history :
35- history_msg = {
36- "type" : "history" ,
37- "messages" : self .message_history
38- }
35+ history_msg = {"type" : "history" , "messages" : self .message_history }
3936 server .send (json .dumps (history_msg ))
4037
4138 # Send a welcome message
4239 welcome_msg = {
4340 "type" : "system" ,
4441 "text" : "Connected to chatroom" ,
45- "timestamp" : self .get_timestamp ()
42+ "timestamp" : self .get_timestamp (),
4643 }
4744 server .send (json .dumps (welcome_msg ))
4845
@@ -62,7 +59,7 @@ async def webSocketMessage(self, ws, message):
6259 "type" : "message" ,
6360 "username" : data .get ("username" , "Anonymous" ),
6461 "text" : data .get ("text" , "" ),
65- "timestamp" : self .get_timestamp ()
62+ "timestamp" : self .get_timestamp (),
6663 }
6764
6865 # Add to history
@@ -113,7 +110,9 @@ async def fetch(self, request):
113110 # Serve the HTML page for the root path
114111 if pathname == "/" :
115112 html_file = Path (__file__ ).parent / "chatroom.html"
116- return Response (html_file .read_text (), headers = {"Content-Type" : "text/html" })
113+ return Response (
114+ html_file .read_text (), headers = {"Content-Type" : "text/html" }
115+ )
117116
118117 # Handle room requests: /room/<name>
119118 if pathname .startswith ("/room/" ):
@@ -132,4 +131,6 @@ async def fetch(self, request):
132131 # Forward the request to the Durable Object
133132 return await stub .fetch (request )
134133
135- return Response ("Not found. Use /room/<name> to connect to a chatroom." , status = 404 )
134+ return Response (
135+ "Not found. Use /room/<name> to connect to a chatroom." , status = 404
136+ )
0 commit comments