20 lines
605 B
Python
Executable File
20 lines
605 B
Python
Executable File
#!/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)
|