You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB
Python

2 years ago
import typing as t
import os
from flask import Flask
2 years ago
from flask import render_template
2 years ago
from .config import secret_key, wtf_csrf_secret_key
2 years ago
from .routes import main
2 years ago
APPPATH = os.path.dirname(os.path.abspath(__file__))
templates = os.path.join(APPPATH, "templates")
static = os.path.join(APPPATH, "static")
app = Flask(
"Princely-Acts",
template_folder=templates,
static_folder=static,
static_url_path=''
)
"in case we put a trailing slash at the end of the route's uri"
app.url_map.strict_slashes = False
app.config.update(dict(
SECRET_KEY= secret_key,
WTF_CSRF_SECRET_KEY= wtf_csrf_secret_key
))
@app.before_request
def clear_trailing():
from flask import redirect, request
rp = request.path
if rp != '/' and rp.endswith('/'):
return redirect(rp[:-1])
2 years ago
@app.errorhandler(404)
def page_not_found(e):
2 years ago
return render_template("404.html", title="Page non trouvée"), 404
@app.errorhandler(500)
def internal_server_error(e):
2 years ago
return render_template("500.html", title="Erreur interne du serveur"), 500
2 years ago
app.register_blueprint(main)
2 years ago