#!/usr/bin/python3 
 

import asyncio
try:
  from websockets.asyncio.server import serve
except:
  from websockets import serve
 
async def echo(websocket):
    async for message in websocket:
        print(message)
        await websocket.send(message)

async def main():
    host='localhost'
    async with serve(echo,host, 8888) as server:
        await server.serve_forever()


if __name__ == "__main__":
    asyncio.run(main())

 
 
 
