commit 90b7820678da5d6bdde45d6599c756663de526a9 Author: Clément Martin Date: Sun Feb 26 20:24:11 2023 +0100 Initial version diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bee8a64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/README.md b/README.md new file mode 100644 index 0000000..0e54359 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Sorry. + +Minimalist sorry server using flask. diff --git a/sorry.py b/sorry.py new file mode 100755 index 0000000..a6dbcc6 --- /dev/null +++ b/sorry.py @@ -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('/') +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) diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..323901f --- /dev/null +++ b/templates/index.html @@ -0,0 +1,8 @@ + +Sorry. :-( +

Hello Stranger

+{% if vhost %} +

Unfortunately, the host {{ vhost }} is not available at the moment, most likely it is because it was powered off.

+{% else %} +

It looks like you are doing something wrong, we have nothing interresting to see here.

+{% endif %}