Initially, I wanted to have python (somehow) directly manipulate the DOM based on the state of
document.monetization.state. I didn't know if it was possible but I figured there must be a way because, well, it's python.
After trying out a couple of ways, I realized it's just not as simple as I thought to access
document from python and still keep the project free from a whole bunch of dependencies. As a solution, I think I have to include a small js script to provide an interface between what's going on in the browser and the backend.
I've been a bit hesitant to take this approach because I wanted to keep it all python, but this seems like the best thing to do for now.
So, the idea remains the same. I still want to be able to do
from monetize import check_state @app.route('/monetized') def monetized_page(): state = check_state() if state == 'started': # implement logic to offer monetized content else: # do something else
It's just how to achieve it that's changing.