From 39223823d97eca91bf20eff9e18ce82b1973ec92 Mon Sep 17 00:00:00 2001 From: Marc Brinkmann Date: Sat, 22 Feb 2014 17:04:28 +0100 Subject: [PATCH] Use current_app instead of hard-coupling extension to app. This is good practice, regardless of whether Blueprints will be supported! --- flask_sslify.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/flask_sslify.py b/flask_sslify.py index fcbf21e..2929f9f 100644 --- a/flask_sslify.py +++ b/flask_sslify.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from flask import request, redirect +from flask import request, redirect, current_app YEAR_IN_SECS = 31536000 @@ -19,7 +19,6 @@ class SSLify(object): def init_app(self, app): """Configures the configured Flask app to enforce SSL.""" - self.app = app app.before_request(self.redirect_to_ssl) app.after_request(self.set_hsts_header) @@ -38,7 +37,7 @@ class SSLify(object): # Should we redirect? criteria = [ request.is_secure, - self.app.debug, + current_app.debug, request.headers.get('X-Forwarded-Proto', 'http') == 'https' ]