Fixed bug when initializing SSLify without 'app' argument and using init_app(app) to

set it later.
This commit is contained in:
Jeffrey Gelens
2013-07-18 09:43:09 +02:00
parent 5572862701
commit 9c12df10c4
+3 -1
View File
@@ -8,7 +8,7 @@ YEAR_IN_SECS = 31536000
class SSLify(object):
"""Secures your Flask App."""
def __init__(self, app, age=YEAR_IN_SECS, subdomains=False, permanent=False):
def __init__(self, app=None, age=YEAR_IN_SECS, subdomains=False, permanent=False):
if app is not None:
self.app = app
self.hsts_age = age
@@ -21,6 +21,8 @@ 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)