CDN support¶
Flask-Bootstrap supports delivery via CDN or local resources, configurable at
runtime. Upon initialization, Flask-Bootstrap will store a dictionary on your
app named yourapp.extensions['bootstrap']['cdns']
, which maps names to
CDN
instances.
You can use bootstrap_find_resource()
in your
templates as well when using other resources that may be available on CDNs.
CDNs can be added by adding new entries to the dictionary mention above.
-
class
flask_bootstrap.
CDN
¶ Base class for CDN objects.
-
get_resource_url
(filename)¶ Return resource url for filename.
-
-
class
flask_bootstrap.
StaticCDN
(static_endpoint='static', rev=False)¶ A CDN that serves content from the local application.
Parameters: - static_endpoint – Endpoint to use.
- rev – If
True
, honorBOOTSTRAP_QUERYSTRING_REVVING
.
-
class
flask_bootstrap.
WebCDN
(baseurl)¶ Serves files from the Web.
Parameters: baseurl – The baseurl. Filenames are simply appended to this URL.
-
flask_bootstrap.
bootstrap_find_resource
(filename, cdn, use_minified=None, local=True)¶ Resource finding function, also available in templates.
Tries to find a resource, will force SSL depending on
BOOTSTRAP_CDN_FORCE_SSL
settings.Parameters: - filename – File to find a URL for.
- cdn – Name of the CDN to use.
- use_minified' – If set to
True
/False
, use/don’t use minified. IfNone
, honorsBOOTSTRAP_USE_MINIFIED
. - local – If
True
, uses thelocal
-CDN whenBOOTSTRAP_SERVE_LOCAL
is enabled. IfFalse
, uses thestatic
-CDN instead.
Returns: A URL.