Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import websockets
|
| 3 |
+
|
| 4 |
+
async def echo(websocket, path):
|
| 5 |
+
async for message in websocket:
|
| 6 |
+
await websocket.send(message)
|
| 7 |
+
|
| 8 |
+
async def main():
|
| 9 |
+
async with websockets.serve(echo, "localhost", 8765):
|
| 10 |
+
await asyncio.Future() # Keeps the server running indefinitely
|
| 11 |
+
|
| 12 |
+
asyncio.run(main())
|