Utilizing WebSocket in GPIO binary sensor

Are there any examples/tutorials of codes, such as the ones run in Python, that handles sensor (binary one that has ON/OFF as output) with WebSocket? (help to display the results in HA Lovelace UI, if possible too).