Initial version

This commit is contained in:
Clément Martin 2023-02-26 20:24:11 +01:00
commit 90b7820678
4 changed files with 31 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# Sorry.
Minimalist sorry server using flask.

19
sorry.py Executable file
View 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
View 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 %}