import typing as t import os from flask import Flask from flask import render_template from .config import secret_key, wtf_csrf_secret_key from .routes import main 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]) @app.errorhandler(404) def page_not_found(e): return render_template("404.html", title="Page non trouvée"), 404 @app.errorhandler(500) def internal_server_error(e): return render_template("500.html", title="Erreur interne du serveur"), 500 app.register_blueprint(main)