瀏覽代碼

code review

Falko Schindler 1 年之前
父節點
當前提交
3032da2426
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      examples/websockets/main.py

+ 4 - 4
examples/websockets/main.py

@@ -1,7 +1,7 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """Websockets example showing messages from connected clients and broadcasting via button click.
 
-NOTE: NiceGUI already handles all the communication for you so you don't need to worry about websockets and the like normally.
+NOTE: NiceGUI already handles all the communication for you, so you don't need to worry about websockets and the like normally.
 This example is only for advanced use cases where you want to allow other, non-NiceGUI clients to connect to your server.
 """
 import asyncio
@@ -27,7 +27,7 @@ messages = ui.column().classes('ml-4')
 
 
 async def handle_connect(websocket: WebSocketServerProtocol):
-    '''Register the new websocket connection, handle incoming messages and remove the connection when it is closed.'''
+    """Register the new websocket connection, handle incoming messages and remove the connection when it is closed."""
     try:
         CONNECTIONS.add(websocket)
         connections_label.text = len(CONNECTIONS)
@@ -40,7 +40,7 @@ async def handle_connect(websocket: WebSocketServerProtocol):
 
 
 async def start_websocket_server():
-    async with websockets.serve(handle_connect, "localhost", 8765):
+    async with websockets.serve(handle_connect, 'localhost', 8765):
         await asyncio.Future()
 
 # start the websocket server when NiceGUI server starts