Initial version
This commit is contained in:
commit
90b7820678
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
__pycache__
|
||||||
19
sorry.py
Executable file
19
sorry.py
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# Copyright (c) 2022 Clément Martin twisla@twis.la. All rights reserved.
|
||||||
|
# Unauthorized copying of this file, via any medium is strictly prohibited
|
||||||
|
|
||||||
|
import re
|
||||||
|
from flask import Flask, render_template, request
|
||||||
|
from markupsafe import Markup
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/', defaults={'path': ''})
|
||||||
|
@app.route('/<path:path>')
|
||||||
|
def index(path):
|
||||||
|
wildcard = re.compile('.+\.home\.twis\.la')
|
||||||
|
raw_host = request.headers.get('Host')
|
||||||
|
vhost = Markup.escape(raw_host)
|
||||||
|
if not wildcard.match(vhost):
|
||||||
|
vhost = None
|
||||||
|
return render_template('index.html', vhost=vhost)
|
||||||
8
templates/index.html
Normal file
8
templates/index.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<title>Sorry. :-(</title>
|
||||||
|
<h1>Hello Stranger</h1>
|
||||||
|
{% if vhost %}
|
||||||
|
<p>Unfortunately, the host <strong>{{ vhost }}</strong> is not available at the moment, most likely it is because it was powered off.</p>
|
||||||
|
{% else %}
|
||||||
|
<p>It looks like you are doing something wrong, we have nothing interresting to see here.</p>
|
||||||
|
{% endif %}
|
||||||
Loading…
x
Reference in New Issue
Block a user