def init_app(self, app):
delivery_method = app.config.get("ASSETS_DELIVERY_METHOD")
if delivery_method and delivery_method.upper() in ["S3", "CDN"]:
#with app.app_context():
is_secure = False #request.is_secure
if delivery_method.upper() == "CDN":
domain = app.config.get("ASSETS_DELIVERY_DOMAIN")
if "://" in domain:
domain_parsed = utils.urlparse(domain)
is_secure = domain_parsed.scheme == "https"
domain = domain_parsed.netloc
app.config.setdefault("S3_CDN_DOMAIN", domain)
app.config["FLASK_ASSETS_USE_S3"] = True
app.config["FLASKS3_ACTIVE"] = True
app.config["FLASKS3_URL_STYLE"] = "path"
app.config.setdefault("FLASKS3_USE_HTTPS", is_secure)
app.config.setdefault("FLASKS3_ONLY_MODIFIED", True)
app.config.setdefault("FLASKS3_GZIP", True)
app.config.setdefault("FLASKS3_BUCKET_NAME", app.config.get("AWS_S3_BUCKET_NAME"))
super(self.__class__, self).init_app(app)
评论列表
文章目录