Falko Schindler 1 ano atrás
pai
commit
3032da2426
1 arquivos alterados com 4 adições e 4 exclusões
  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.
 """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.
 This example is only for advanced use cases where you want to allow other, non-NiceGUI clients to connect to your server.
 """
 """
 import asyncio
 import asyncio
@@ -27,7 +27,7 @@ messages = ui.column().classes('ml-4')
 
 
 
 
 async def handle_connect(websocket: WebSocketServerProtocol):
 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:
     try:
         CONNECTIONS.add(websocket)
         CONNECTIONS.add(websocket)
         connections_label.text = len(CONNECTIONS)
         connections_label.text = len(CONNECTIONS)
@@ -40,7 +40,7 @@ async def handle_connect(websocket: WebSocketServerProtocol):
 
 
 
 
 async def start_websocket_server():
 async def start_websocket_server():
-    async with websockets.serve(handle_connect, "localhost", 8765):
+    async with websockets.serve(handle_connect, 'localhost', 8765):
         await asyncio.Future()
         await asyncio.Future()
 
 
 # start the websocket server when NiceGUI server starts
 # start the websocket server when NiceGUI server starts