Websocket standard and asyncio extensions (#55)

This commit is contained in:
Miguel Grinberg
2022-09-03 20:04:34 +01:00
committed by GitHub
parent ec0f9ba855
commit 2399c29c8a
27 changed files with 1077 additions and 60 deletions

View File

@@ -0,0 +1,20 @@
from microdot import Microdot, send_file
from microdot_websocket import with_websocket
app = Microdot()
@app.route('/')
def index(request):
return send_file('index.html')
@app.route('/echo')
@with_websocket
def echo(request, ws):
while True:
data = ws.receive()
ws.send(data)
app.run()