RFCartography/rfcartography/routing.py

36 lines
1.2 KiB
Python
Raw Normal View History

2023-01-03 14:42:54 +01:00
from flask import Flask, Blueprint, redirect, url_for, render_template, abort
from werkzeug.wrappers import Response
from rfcartography.search import search
from rfcartography.details import details
def register_routers(app: Flask) -> None:
@app.route('/imprint')
def imprint() -> tuple[str, int]:
if not 'IMPRINT' in app.config:
abort(404)
content: dict = {'title': 'Imprint',
'content': app.config['IMPRINT']}
return render_template('generic.html', **content), 200
@app.route('/privacy')
def privacy() -> tuple[str, int]:
if not 'PRIVACY' in app.config:
abort(404)
content: dict = {'title': 'Privacy',
'content': app.config['PRIVACY']}
return render_template('generic.html', **content), 200
# answer favicon requests
@app.route('/favicon.ico')
def favicon() -> Response:
return redirect(url_for('static', filename='favicon.svg'))
static = Blueprint('static',
__name__,
static_folder='static')
app.register_blueprint(static)
app.register_blueprint(search)
app.register_blueprint(details)
return