pythonasyncioeventletgeventlong-pollinglow-latencysocket-iosocketiosocketio-serverweb-serverwebsocket
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
394 B
22 lines
394 B
#!/usr/bin/env python
|
|
import uvicorn
|
|
|
|
import socketio
|
|
|
|
sio = socketio.AsyncServer(async_mode="asgi")
|
|
app = socketio.ASGIApp(
|
|
sio,
|
|
static_files={
|
|
"/": "latency.html",
|
|
"/static": "static",
|
|
},
|
|
)
|
|
|
|
|
|
@sio.event
|
|
async def ping_from_client(sid):
|
|
await sio.emit("pong_from_server", room=sid)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run(app, host="127.0.0.1", port=5000)
|
|
|