fit: Render 404 page on error
All checks were successful
Build Docker / Build Image (push) Successful in 22s
All checks were successful
Build Docker / Build Image (push) Successful in 22s
This commit is contained in:
parent
81660ae769
commit
357632e465
17
server.py
17
server.py
@ -12,13 +12,28 @@ def send_report(path):
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
https_redirect="<script src=\"https://nathan.woodburn/https.js\"></script>"
|
||||
|
||||
# Get host from request
|
||||
host = request.headers.get('host')
|
||||
tld = host.split('.')[-1]
|
||||
tld = tld.split(':')[0]
|
||||
if tld == 'localhost' or tld == '1':
|
||||
tld = 'example'
|
||||
return render_template('index.html', tld=tld)
|
||||
https_redirect = ""
|
||||
|
||||
|
||||
return render_template('index.html', tld=tld, https_redirect=https_redirect)
|
||||
|
||||
# 404 catch all
|
||||
@app.errorhandler(404)
|
||||
def not_found(e):
|
||||
host = request.headers.get('host')
|
||||
tld = host.split('.')[-1]
|
||||
tld = tld.split(':')[0]
|
||||
if tld == 'localhost' or tld == '1':
|
||||
tld = 'example'
|
||||
return render_template('404.html', tld=tld), 404
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=False, port=5000, host='0.0.0.0')
|
@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
|
||||
<title>.tas/ domains</title>
|
||||
<title>.{{tld}}/ domains</title>
|
||||
<meta name="description" content=".tas/ domains">
|
||||
<link rel="icon" type="image/png" sizes="1024x1024" href="assets/img/favicon.png">
|
||||
<link rel="icon" type="image/png" sizes="1024x1024" href="assets/img/favicon.png">
|
||||
@ -21,7 +21,7 @@
|
||||
<div style="display: inline-block;text-align: left;">
|
||||
<code><span>this_page</span>.<em>not_found</em> = true;</code>
|
||||
<code><span>if</span> (<b>you_spelt_it_wrong</b>){<br><span>autocorrect</span>.<em>enable</em>();<br>}</code>
|
||||
<code><span>else if</span> (<b>we_screwed_up</b>){<br><em>alert</em>(<i>"Strewth mate, you're lost! Fair dinkum, why are you here?"</i>);<br><span>window</span>.<em>location</em> = home;<br>}</code>
|
||||
<code><span>else if</span> (!<em>exists</em>(<b>location</b>)){<br><em>alert</em>(<i>"You're lost! I'll send you back home"</i>);<br><span>window</span>.<em>location</em> = home;<br>}</code>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -30,14 +30,13 @@
|
||||
<script type="text/javascript">
|
||||
function callback(){
|
||||
return function(){
|
||||
alert("Strewth mate, you're lost! Fair dinkum, why are you here?");
|
||||
alert("You're lost! I'll send you back home");
|
||||
window.location = '/';
|
||||
}
|
||||
}
|
||||
var a = "world";
|
||||
setTimeout(callback(), 5000);
|
||||
|
||||
|
||||
</script>
|
||||
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="assets/js/404.js"></script>
|
||||
|
@ -46,7 +46,7 @@
|
||||
<a href="https://nathan.woodburn.au" target="_blank">Nathan.Woodburn/</a>
|
||||
</span>
|
||||
</footer>
|
||||
<script src="https://nathan.woodburn/https.js"></script>
|
||||
{{https_redirect | safe}}
|
||||
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user