write a minimal websockets server in python
- User
write a minimal websockets server in python
- Assistant
Here's a minimal WebSocket server in Python using the
websocketslibrary:import asyncio import websockets async def handle_connection(websocket, path): async for message in websocket: print(f"Received message: {message}") await websocket.send(f"You said: {message}") async def main(): async with websockets.serve(handle_connection, "localhost", 8765): await asyncio.Future() # Run forever if __name__ == "__main__": asyncio.run(main())
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.