Uncategorized · April 27, 2021

Add Brave Rewards Verification to you Flask App

Being Brave Publisher, you need to verify that you are owner of the website. Here is how to do this on your Flask web application.

Image: unsplash

Verification process

Usually, you need to put some verification text file into your .well-known root folder. But flask app have it own route management. So you cannot just easily upload verification text file to your web server.

Solution

You need to add a route into your flask app. Sample code below.

@app.route('/.well-known/brave-rewards-verification.txt')
def brave_reward_check():
    brave_response = {
        """This is a Brave Rewards publisher verification file.

Domain: YOUR_DOMAIN.COM
Token: YOUR_TOKEN"""
    }
    return Response(brave_response, mimetype='text/plain')

Replace YOUR_DOMAIN.COM and YOUR_TOKEN with your own information.

Hope this help for all Brave and Flask lover 😉