Flask-Bower provides a method to manage and serve bower installed packages. This simplifies javascript dependency management a lot.
To provide this, there is a flask blueprint to serve content from your bower_components directory and use url_for() for serving the files same as serving files form flask static folder.
Usage
from flask_bower import Bower [...] Bower(app)
Now it should look like:
$ ls -1 app/bower_components/jquery MIT-LICENSE.txt bower.json dist src
To include and use this, you can use url_for():
<script src="{{ url_for('bower.static', filename='jquery/dist/jquery.js') }}"></script>
Configuration
There are several configuration options to customize the behavior:
- BOWER_COMPONENTS_ROOT
default: bower_components
Directory name containing your installed bower packages
- BOWER_KEEP_DEPRECATED
default: True
Keep deprecated functions available
Note: deprecated functions will be removed in future versions
affected functions:
bower_url_for - please migrate to url_for('bower.static', filename='component/path')
- BOWER_QUERYSTRING_REVVING
default: True
Append ?version= parameter to url (useful for cache busting by updates). It tries to detect the version in the following order:
bower.json
package.json (if available)
file modification timestamp
- BOWER_REPLACE_URL_FOR
default: False
Replace flasks url_for() function in templates.
This is useful - but not recommended - to build an “overlay” for the static folder.
Warning: Replacing url_for() causes conflicts with other flask extensions like flask-cdn, since only one extension can replace url_for() at a time and the last registered extension wins.
- BOWER_SUBDOMAIN
default: None
Subdomain to serve the content like static (see flask blueprint documentation for subdomains)
- BOWER_TRY_MINIFIED
default: True
Check if a minified version is available and serve this instead (check if a file with <filename>.min.<ext> like jquery/dist/jquery.min.js exists)
- BOWER_URL_PREFIX
default: /bower
Customize the url prefix
Deprecations
bower_url_for(component, file)
This is now deprecated since it is a break of the development workflow due to the use of a different function than url_for(), which is the default for url handling in flask.Since v1.1.0 it is possible to use the default url_for() function also for flask assets::url_for('bower.static', filename='component/path')Use of this new approach is recommended to all developers and to simplify the migration the bower_url_for() function will stay available for a while; though it can be disabled to help migrating (see BOWER_KEEP_DEPRECATED)
Metadata
Release files for Flask-Bower 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| Flask-Bower-2.0.0.tar.gz | 21.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Flask_Bower-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.0 kB
Release files / Flask-Bower-2.0.0.tar.gz
| Download URL | Flask-Bower-2.0.0.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d44aef9f698f98c2b1ba5c29ee0ba967aaefb1a141a4c3244de4dabfc7ad9fd9
|
|
BLAKE2b-256 checksum How to use checksums |
b497cfa4b8b28cc271831785c1142e46af6ce36c93c7c0abdaff78bd32e091ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.6
|
Release files / Flask_Bower-2.0.0-py3-none-any.whl
| Download URL | Flask_Bower-2.0.0-py3-none-any.whl |
|---|---|
| Size | 18.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
959880b917de6a9ddee3b20d2926a56c6becca34a6b5d123cadc01f5b5c944fa
|
|
BLAKE2b-256 checksum How to use checksums |
f982c309327f13e6f24a2e79f52e97818160a229a035b78d741a3cda25e0262b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.6
|
Security for Flask-Bower 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.