Real Time Response esp32 web server

When i turn on light manually than i didn't get response without refreshing page

Yas i can do that with small amount of relays and swiches but using multiple state1,and state2 and so on it's work fine but here i want a small code that i can get update of button when i'm turn on relays manually without lot's of code lines for each button state single function

When i call that Singal function it's check all relay states and update associated buttons without refreshing entire page