25 lines
775 B
Python

import asyncio
from quart import Quart, Response, websocket
from glebby.connection_manager import ConnectionManager
from glebby.model import Model
connection_manager = ConnectionManager()
model = Model(connection_manager)
# Files in ./static are served directly under / instead of under /static
app = Quart(__name__, static_url_path='')
# Root route should point to ./static/index.html
@app.route('/')
async def root() -> Response:
return await app.send_static_file('index.html')
# Every time a websocket connection to /glebby is opened, a new connection
# is set up in the connection manager. It will handle sending and receiving
# and keeping the model up to date.
@app.websocket('/glebby')
async def ws() -> None:
await connection_manager.setup_connection()