You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
473 B
22 lines
473 B
2 years ago
|
# WS server that sends messages every second
|
||
|
|
||
|
import asyncio
|
||
|
import datetime
|
||
|
import random
|
||
|
import websockets
|
||
|
import ssl
|
||
|
|
||
|
async def time(websocket, path):
|
||
|
while True:
|
||
|
with open('/var/www/html/folds.html') as myinput:
|
||
|
folds = myinput.read()
|
||
|
print(folds)
|
||
|
await websocket.send(folds)
|
||
|
await asyncio.sleep(1)
|
||
|
|
||
|
start_server = websockets.serve(time, "0.0.0.0", 5678)
|
||
|
|
||
|
asyncio.get_event_loop().run_until_complete(start_server)
|
||
|
asyncio.get_event_loop().run_forever()
|
||
|
|