How can i check for an on_button_press in an ejs website using python

Hi, if i have an ejs file, and i am running it on a port on my browser, how can i check for an on_button_press in python? I am thinking on using flask but i don’t really know how.

Any help is good, preferable with examples. Thanks