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.

31 lines
641 B

from aiohttp import web
import socketio
sio = socketio.AsyncServer(async_mode="aiohttp")
app = web.Application()
sio.attach(app)
async def index(request):
with open("fiddle.html") as f:
return web.Response(text=f.read(), content_type="text/html")
@sio.event
async def connect(sid, environ, auth):
print(f"connected auth={auth} sid={sid}")
await sio.emit("hello", (1, 2, {"hello": "you"}), to=sid)
@sio.event
def disconnect(sid, reason):
print("disconnected", sid, reason)
app.router.add_static("/static", "static")
app.router.add_get("/", index)
if __name__ == "__main__":
web.run_app(app, port=5000)