Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-Upstatic-0.0.6.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file Flask-Upstatic-0.0.6.tar.gz.

File metadata

File hashes

Hashes for Flask-Upstatic-0.0.6.tar.gz
Algorithm Hash digest
SHA256 d006f3da8c8f006c1e4bd11dbd1fe3ce04f52391a3a99f5bbe4b776ce7b40dc0
MD5 2844e7cfb3a05103020bef3821c190d6
BLAKE2b-256 3f4369f31d784111cae84681277e981f9a15c32d2aa3191ebf145c72f3146d0c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page