For this hackathon, I'm thinking of building a python binding for the web monetization API. Here's what I have in mind:
According to the docs, if you want to check if a user is web monetized, you check the state using:
document.monetization.state
You would then proceed to implement your logic based on the state.
As a backend python developer, it would be cool if I could do that in python. If I'm using Flask for example, and I have a monetized route, I would want to write something like:
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
This is a simple example but that's the general idea - to have all the methods exposed by the js API in python. Javascript would of course still be working behind the scenes once this gets to the browser.
I believe something like this would make it easier to implement the monetization API for python developers working with web frameworks like flask and django.
Top comments (4)
When I saw this hackathon my first thought was how could this be made relevant to backend devs, as a backend dev myself. This is a great idea! Excited to see the progress on it.
You inspired me actually, and I'm putting together some Rack middleware to handle the web monetization API for the Ruby backend developer :)
update, it's posted!
Rack Middleware for the Web Monetization API
Ben Greenberg ・ May 14 ・ 3 min read
Wow, that was fast 😀
Neat!