Skip to content

Commit a6b2691

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 3dbd184 commit a6b2691

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

15-chatroom/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# WebSocket chatroom
1+
# WebSocket chatroom

15-chatroom/src/entry.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)