diff --git a/Dockerfile b/Dockerfile index aeddcb4..984bd84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,6 @@ COPY . /app VOLUME /data ENTRYPOINT ["python3"] -CMD ["main.py"] +CMD ["server.py"] FROM builder as dev-envs \ No newline at end of file diff --git a/gift.py b/gift.py index 591cfbf..1bd81c7 100644 --- a/gift.py +++ b/gift.py @@ -13,7 +13,7 @@ nbcookie = os.getenv('cookie') cookies = {"namebase-main": nbcookie} nb_endpoint = "https://www.namebase.io/" -max_price = 4 # Max price to buy a domain at (in HNS) +max_price = 5 # Max price to buy a domain at (in HNS) def gift(name,email,referer, ip): @@ -104,6 +104,10 @@ def gift(name,email,referer, ip): # Add this name to gifts record gifts[-1]['domain'] = domain + # Save the file + with open(path, 'w') as f: + json.dump(gifts, f) + send_name = requests.post(nb_endpoint + "/api/gift/" + domain.strip(),headers=headers,data=json.dumps(params), cookies=cookies) diff --git a/main.py b/main.py index 7cc393e..dbd827c 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ import os import dotenv import requests import gift +import json app = Flask(__name__) dotenv.load_dotenv() @@ -60,16 +61,46 @@ def send_wallet(token): address = requests.get('https://nathan.woodburn.au/.well-known/wallets/'+token).text return make_response(address, 200, {'Content-Type': 'text/plain'}) +@app.route('/stats') +def stats(): + # Read the file + path = '/data/gifts.json' + if os.getenv('local') == 'true': + path = './gifts.json' + + # Load file + gifts = [] + if os.path.isfile(path): + with open(path, 'r') as f: + gifts = json.load(f) + + # Loop through gifts + referals = {} + for gift in gifts: + if gift['referer'] not in referals: + referals[gift['referer']] = 1 + else: + referals[gift['referer']] += 1 + + statsHTML = 'Total gifts: ' + str(len(gifts)) + '

' + statsHTML += 'Referals:
' + for referal in referals: + statsHTML += referal + ': ' + str(referals[referal]) + '
' + + + + + return render_template('stats.html',address=address,stats=statsHTML) @app.route('/') def catch_all(path): - # If file exists, load it - if os.path.isfile('templates/' + path): - return render_template(path) + # # If file exists, load it + # if os.path.isfile('templates/' + path): + # return render_template(path) - # Try with .html - if os.path.isfile('templates/' + path + '.html'): - return render_template(path + '.html') + # # Try with .html + # if os.path.isfile('templates/' + path + '.html'): + # return render_template(path + '.html') return redirect('/') # 404 catch all diff --git a/templates/stats.html b/templates/stats.html new file mode 100644 index 0000000..6c1ac1e --- /dev/null +++ b/templates/stats.html @@ -0,0 +1,105 @@ + + + + + + + Home - Woodburn Faucet + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+

Nathan.Woodburn/

+

Woodburn Faucet Stats

+
+
+
+
+

{{stats | safe}}

+

If you need any help with your domain you can ask in the Namebase discord server or by emailing my at faucet@nathan.woodburn.au

+
+
+
+
+
+
+
+

Donate to fund the faucet

+

{{address}}

+
+
+
+
+
+
+

Our Services

+

What we can do for you

+
+
+
+
+
+
+
+
web
+
HNS Hosting
+

Providing website hosting for Handshake domains. Wordpress sites or static html sites.

Learn more +
+
+
+
+
+
+
dns
+
Woodburn Registry
+

Free Handshake compatible DNS server. Also provides free SLDs for testing

Learn more +
+
+
+
+
+
+
+ + + + + + \ No newline at end of file