fix: Don't show loader to google crawler
All checks were successful
Build Docker / BuildImage (push) Successful in 1m10s

This commit is contained in:
Nathan Woodburn 2024-07-01 11:37:19 +10:00
parent fb8136f3b6
commit eea21cea1e
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
4 changed files with 25 additions and 32 deletions

View File

@ -6,3 +6,4 @@ requests
cloudflare
qrcode
ansi2html
cachetools

View File

@ -9,13 +9,13 @@ import datetime
import qrcode
import re
from ansi2html import Ansi2HTMLConverter
from functools import cache
app = Flask(__name__)
CORS(app)
dotenv.load_dotenv()
address = ''
handshake_scripts = '<script src="https://nathan.woodburn/handshake.js" domain="nathan.woodburn" async></script><script src="https://nathan.woodburn/https.js" async></script>'
restricted = ['ascii']
@ -30,11 +30,12 @@ if os.path.isfile('data/sites.json'):
projects = []
projectsUpdated = 0
def getAddress():
global address
if address == '':
address = 'hs1qv3uu4amv87g7p7h49xez2pmzwjf92am0wzpnh4'
@cache
def getAddress(coin:str) -> str:
address = ''
if os.path.isfile('.well-known/wallets/' + coin.upper()):
with open('.well-known/wallets/' + coin.upper()) as file:
address = file.read()
return address
#Assets routes
@ -110,20 +111,6 @@ def removeTrailingSlash():
@app.route('/.well-known/wallets/<path:path>')
def wallet(path):
# If HNS, redirect to HNS wallet
if path == "HNS":
# Get from 100.66.107.77:8080 then return result
# Check for cookie
if request.cookies.get('HNS'):
return make_response(request.cookies.get('HNS'), 200, {'Content-Type': 'text/plain'})
address = getAddress()
# Set cookie
resp = make_response(address, 200, {'Content-Type': 'text/plain'})
# Cookie should last 1 week
resp.set_cookie('HNS', address, max_age=604800)
return resp
if path[0] == ".":
return send_from_directory('.well-known/wallets', path, mimetype='application/json')
elif os.path.isfile('.well-known/wallets/' + path):
@ -181,6 +168,8 @@ def index():
loaded = True
# Check if crawler
if request.user_agent.browser != 'Googlebot' and request.user_agent.browser != 'Bingbot':
# Check if cookie is set
if not request.cookies.get('loaded') and not loaded:
# Set cookie
@ -189,7 +178,6 @@ def index():
return resp
global address
global handshake_scripts
global projects
global projectsUpdated
@ -257,10 +245,14 @@ def index():
if request.host == "localhost:5000" or request.host == "127.0.0.1:5000" or os.getenv('dev') == "true" or request.host == "test.nathan.woodburn.au":
handshake_scripts = ""
address = getAddress()
HNSaddress = getAddress("HNS")
SOLaddress = getAddress("SOL")
BTCaddress = getAddress("BTC")
ETHaddress = getAddress("ETH")
# Set cookie
resp = make_response(render_template('index.html', handshake_scripts=handshake_scripts,
HNS=address, repo=repo,
HNS=HNSaddress, SOL=SOLaddress, BTC=BTCaddress,
ETH=ETHaddress, repo=repo,
repo_description=repo_description,
custom=custom,sites=sites,projects=projects), 200, {'Content-Type': 'text/html'})
resp.set_cookie('loaded', 'true', max_age=604800)

View File

@ -1 +1 @@
const letters="ABCDEFGHIJKLMNOPQRSTUVWXYZ/.?!@#$%^&*()_+";let interval=null,interval2=null,interval3=null;document.querySelector(".copyright").onmouseover=t=>{let e=0,l="Copyright © Nathan Woodburn 2023";clearInterval(interval2),interval2=setInterval((()=>{t.target.innerText=t.target.innerText.split("").map(((t,r)=>r<e?l[r]:letters[Math.floor(41*Math.random())])).join(""),e>=l.length&&clearInterval(interval2),e+=1/3}),10)};
const letters="ABCDEFGHIJKLMNOPQRSTUVWXYZ/.?!@#$%^&*()_+";let interval=null,interval2=null,interval3=null;document.querySelector(".copyright").onmouseover=t=>{let e=0,l="Copyright © Nathan.Woodburn/ 2024";clearInterval(interval2),interval2=setInterval((()=>{t.target.innerText=t.target.innerText.split("").map(((t,r)=>r<e?l[r]:letters[Math.floor(41*Math.random())])).join(""),e>=l.length&&clearInterval(interval2),e+=1/3}),10)};

View File

@ -163,7 +163,7 @@ Check them out here!</blockquote><img class="img-fluid" src="/assets/img/pfront.
<li class="list-inline-item">&nbsp;<a class="btn btn-primary btn-lg btn-default" role="button" href="https://github.com/sponsors/Nathanwoodburn" style="width: 170px;" target="_blank"><i class="fab fa-github fa-fw"></i><span class="network-name">&nbsp; Github</span></a></li>
<li class="list-inline-item">&nbsp;<a class="btn btn-primary btn-lg btn-default" role="button" href="https://donate.stripe.com/8wM6pv0VD08Xe408ww" style="width: 170px;" target="_blank"><i class="fab fa-stripe-s fa-fw"></i><span class="network-name">&nbsp;Stripe</span></a></li>
</ul>
<p>HNS:<br><code data-bs-toggle="tooltip" data-bss-tooltip="" id="hns-domain" class="hns" style="color: rgb(242,90,5);display: block;" title="Click to copy">nathan.woodburn</code><code data-bs-toggle="tooltip" data-bss-tooltip="" id="hns" class="hns" style="color: rgb(242,90,5);display: block;" title="Click to copy">{{HNS}}</code><br>BTC:<br><code data-bs-toggle="tooltip" data-bss-tooltip="" id="btc" class="btc" style="color: rgb(242,90,5);display: block;" title="Click to copy">bc1qhs94zzcw64qnwq4hvk056rwxwvgrkd7tq7d4xw</code><br>SOL:<br><code data-bs-toggle="tooltip" data-bss-tooltip="" id="sol-domain" class="sol" style="color: rgb(242,90,5);display: block;" title="Click to copy">woodburn.sol</code><code data-bs-toggle="tooltip" data-bss-tooltip="" id="sol" class="sol" style="color: rgb(242,90,5);display: block;" title="Click to copy">AJsPEEe6S7XSiVcdZKbeV8GRp1QuhFUsG8mLrqL4XgiU</code><br>ETH:<br><code data-bs-toggle="tooltip" data-bss-tooltip="" id="eth-domain" class="eth" style="color: rgb(242,90,5);display: block;" title="Click to copy">woodburn.au</code><code data-bs-toggle="tooltip" data-bss-tooltip="" id="eth" class="eth" style="color: rgb(242,90,5);display: block;" title="Click to copy">0x6cB4B39bEc23a921C9a20D061Bf17d4640B0d39e</code><a class="btn btn-primary btn-default" role="button" href="/donate" style="width: 170px;margin-top: 10px;">OTHER OPTIONS</a></p>
<p>HNS:<br><code data-bs-toggle="tooltip" data-bss-tooltip="" id="hns-domain" class="hns" style="color: rgb(242,90,5);display: block;" title="Click to copy">nathan.woodburn</code><code data-bs-toggle="tooltip" data-bss-tooltip="" id="hns" class="hns" style="color: rgb(242,90,5);display: block;" title="Click to copy">{{HNS}}</code><br>BTC:<br><code data-bs-toggle="tooltip" data-bss-tooltip="" id="btc" class="btc" style="color: rgb(242,90,5);display: block;" title="Click to copy">{{BTC}}</code><br>SOL:<br><code data-bs-toggle="tooltip" data-bss-tooltip="" id="sol-domain" class="sol" style="color: rgb(242,90,5);display: block;" title="Click to copy">woodburn.sol</code><code data-bs-toggle="tooltip" data-bss-tooltip="" id="sol" class="sol" style="color: rgb(242,90,5);display: block;" title="Click to copy">{{SOL}}</code><br>ETH:<br><code data-bs-toggle="tooltip" data-bss-tooltip="" id="eth-domain" class="eth" style="color: rgb(242,90,5);display: block;" title="Click to copy">woodburn.au</code><code data-bs-toggle="tooltip" data-bss-tooltip="" id="eth" class="eth" style="color: rgb(242,90,5);display: block;" title="Click to copy">{{ETH}}</code><a class="btn btn-primary btn-default" role="button" href="/donate" style="width: 170px;margin-top: 10px;">OTHER OPTIONS</a></p>
</div>
</div>
</div>