def init_app(self, app: Flask) -> None: if hasattr(app, 'teardown_appcontext'): app.teardown_appcontext(self.teardown) else: app.teardown_request(self.teardown) self.add_custom_template_filters(app)