feat: Add TLD detection to return TLD page
All checks were successful
Build Docker / Build Image (push) Successful in 25s
All checks were successful
Build Docker / Build Image (push) Successful in 25s
This commit is contained in:
21
server.py
21
server.py
@@ -19,6 +19,8 @@ exchange = {
|
||||
}
|
||||
|
||||
|
||||
tlds = ['australia','newzealand']
|
||||
|
||||
#Assets routes
|
||||
@app.route('/assets/<path:path>')
|
||||
def send_report(path):
|
||||
@@ -374,21 +376,32 @@ def login():
|
||||
@app.route('/')
|
||||
def index():
|
||||
year = datetime.datetime.now().year
|
||||
return render_template('index.html',year=year)
|
||||
hns_scripts = '<script src="https://gday.hnsau/handshake.js" domain="gday.hnsau" async></script><script src="https://gday.hnsau/https.js" async></script>'
|
||||
|
||||
if not request.host in tlds and 'localhost' not in request.host:
|
||||
return render_template('index.html',year=year, handshake_scripts=hns_scripts)
|
||||
|
||||
tld = request.host.split('.')[-1]
|
||||
print(tld)
|
||||
if 'localhost' in tld:
|
||||
tld = tlds[0]
|
||||
hns_scripts = '<script src="https://gday.hnsau/https.js" async></script>'
|
||||
return render_template('/tlds/'+tld+'.html',year=year, handshake_scripts=hns_scripts)
|
||||
|
||||
@app.route('/<path:path>')
|
||||
def catch_all(path):
|
||||
year = datetime.datetime.now().year
|
||||
hns_scripts = '<script src="https://gday.hnsau/handshake.js" domain="gday.hnsau" async></script><script src="https://gday.hnsau/https.js" async></script>'
|
||||
# If file exists, load it
|
||||
if os.path.isfile('templates/' + path):
|
||||
return render_template(path, year=year)
|
||||
return render_template(path, year=year, handshake_scripts=hns_scripts)
|
||||
|
||||
# Try with .html
|
||||
if os.path.isfile('templates/' + path + '.html'):
|
||||
return render_template(path + '.html', year=year)
|
||||
return render_template(path + '.html', year=year, handshake_scripts=hns_scripts)
|
||||
|
||||
if os.path.isfile('templates/' + path.strip('/') + '.html'):
|
||||
return render_template(path.strip('/') + '.html', year=year)
|
||||
return render_template(path.strip('/') + '.html', year=year, handshake_scripts=hns_scripts)
|
||||
|
||||
return render_template('404.html'), 404
|
||||
|
||||
|
||||
Reference in New Issue
Block a user