Opinionated library for working with CDNs in Flask.
Project description
Opinionated library for working with CDNs in Flask.
Configuration
UPSTATIC_DEBUG_USE_LOCAL |
Whether to use local version when in debug mode |
UPSTATIC_S3_ACCESS_KEY_ID |
S3 Access Key ID |
UPSTATIC_S3_SECRET_ACCESS_KEY |
S3 Secret Access Key |
UPSTATIC_S3_BUCKET_NAME |
S3 Bucket Name |
UPSTATIC_S3_KEY_PREFIX |
S3 Key Prefix |
UPSTATIC_S3_CDN_HOST |
S3 CDN Host |
Usage
Initialize extension:
upstatic = Upstatic(app) # or upstatic = Upstatic() upstatic.init_app(app)
Add a static root:
upstatic.add_root('home', '/abs/path/static') upstatic.add_root('home', 'rel/path/static')
Override url_for:
app.add_template_global(upstatic.url_for)
Set a root param in url_for to get static file from named root:
<img src="{{ url_for('static', filename='/images/image.png', root='home') }}">
You can also add static roots from packages:
upstatic.add_root('home', 'static', package_name='home')
Add a root_url to override url building for multiple apps scenarios:
upstatic.add_root('admin', 'static', package_name='admin', root_url='http://localhost:5000/admin/static')
Compile and upload the static files:
upstatic.upload_all('home', 'admin', protocol='http')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file Flask-Upstatic-0.0.6.tar.gz
.
File metadata
- Download URL: Flask-Upstatic-0.0.6.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d006f3da8c8f006c1e4bd11dbd1fe3ce04f52391a3a99f5bbe4b776ce7b40dc0 |
|
MD5 | 2844e7cfb3a05103020bef3821c190d6 |
|
BLAKE2b-256 | 3f4369f31d784111cae84681277e981f9a15c32d2aa3191ebf145c72f3146d0c |