DEV Community

Kelvin Wangonya
Kelvin Wangonya

Posted on

10 6

Progress: rethinking the implementation

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.

While this whole thing can be done much easier in Javascript, I still feel like it's worth providing a python implementation for people who would like to include monetization to their flask/django projects without having to write the javascript themselves.

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
Enter fullscreen mode Exit fullscreen mode

It's just how to achieve it that's changing.

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (2)

Collapse
 
bernardbaker profile image
Bernard Baker

Glad to see you're making progress. We had a team member leave. Well it was more of a no show. No commitment. I'll update everyone with our progress tomorrow 👍.

Collapse
 
thisdotmedia_staff profile image
This Dot Media

Really cool that you're stepping in and trying something different/experimenting! Hope the new implementation goes well. Look forward to your findings 🙏

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay