Realtime ping in flask

Is there any simple way to ping an IP from server, and display realtime console response (every response pack) in browser using flask?

The only idea I see is to ping by 1 package, store it to buffer and take by ajax. But it seems to heavy.

(May be sockets could help, but I’m scared of them, and not shure that I can inject them into, and deal with it easily.)