add demo script using websockets and asyncio

This commit is contained in:
2023-01-29 13:16:41 +01:00
parent 3ec9856ff8
commit d5f0b09fba
4 changed files with 51 additions and 5 deletions

5
app.py Normal file → Executable file
View File

@@ -1,3 +1,4 @@
#!/usr/bin/env python3
from flask import Flask, render_template, url_for, request, redirect, Response, abort, session
from flask_sock import Sock
from flask_sqlalchemy import SQLAlchemy
@@ -28,8 +29,8 @@ def get_date():
date = datetime.now()
return { "now": date.strftime("%Y-%m-%d") }
@sock.route('/<namespace>')
def echo(sock,namespace):
@sock.route('/')
def echo(sock):
while True:
data = json.loads(sock.receive())
sock.send(json.dumps({"method":"set","name":"test","value":"abcd"}))