feat: Add sales count
All checks were successful
Build Docker / Build Image (push) Successful in 28s

This commit is contained in:
Nathan Woodburn 2023-11-03 14:49:45 +11:00
parent 834a9acaa3
commit 20638a1c09
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
4 changed files with 22 additions and 4 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.env

View File

@ -1,2 +1,3 @@
flask flask
python-dotenv python-dotenv
requests

View File

@ -1,6 +1,7 @@
from flask import Flask, make_response, redirect, request, jsonify, render_template, send_from_directory from flask import Flask, make_response, redirect, request, jsonify, render_template, send_from_directory
import os import os
import dotenv import dotenv
import requests
app = Flask(__name__) app = Flask(__name__)
dotenv.load_dotenv() dotenv.load_dotenv()
@ -19,10 +20,22 @@ def index():
tld = host.split('.')[-1] tld = host.split('.')[-1]
tld = tld.split(':')[0] tld = tld.split(':')[0]
if tld == 'localhost' or tld == '1': if tld == 'localhost' or tld == '1':
tld = 'example' tld = 'freeconcept'
https_redirect = "<script>console.log('https.js not loaded on localhost')</script>" https_redirect = "<script>console.log('https.js not loaded on localhost')</script>"
return render_template('index.html', tld=tld, https_redirect=https_redirect) # Count sales
sales = requests.get('https://reg.woodburn.au/api?action=getMyStaked', headers={'Authorization': 'Bearer ' + os.getenv('reg_auth')})
sales = sales.json()
if 'data' not in sales:
return render_template('index.html', tld=tld, https_redirect=https_redirect, sales=0)
tld_sales = 0
sales = sales['data']
for sale in sales:
if sale['tld'] == tld:
print(sale)
tld_sales = sale['slds']
return render_template('index.html', tld=tld, https_redirect=https_redirect, sales=tld_sales)
# 404 catch all # 404 catch all
@app.errorhandler(404) @app.errorhandler(404)

View File

@ -36,7 +36,9 @@
</header> </header>
<section style="font-size: 25px;"> <section style="font-size: 25px;">
<div class="text-center" id="pricing"> <div class="text-center" id="pricing">
<p class="text-center" style="font-weight: bold;">.{{tld}}/ domains now available for registration at Woodburn Registry.</p><span>Get yourname.{{tld}}/</span> <p class="text-center" style="font-weight: bold;">.{{tld}}/ domains now available for registration at Woodburn Registry.</p>
<span>Get yourname.{{tld}}/</span>
<p class="text-center" style="font-weight: bold;">{{sales}} .{{tld}}/ domains claimed so far</p>
</div> </div>
</section> </section>
<footer style="font-size: 25px;background: black;color: white;margin-top: 250px;"> <footer style="font-size: 25px;background: black;color: white;margin-top: 250px;">