sorry/sorry.py
2023-02-26 20:39:56 +01:00

20 lines
549 B
Python
Executable File

#!/usr/bin/env python
# Copyright (c) 2023 Clément Martin twisla@twis.la. All rights reserved.
# See LICENSE file
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)