Skip to main content

Looks for static files in the additional locations as a fallback

Project description

A simple extension that makes it possible to define the additional static locations your Flask application will traverse as a fallback. Miss Django’s STATICFILES_DIRS setting? This mimics that functionallty.

Only works when app.debug is set to True.

Usage

Let’s have an example from the scratch:

>>> from flask.ext.staticify import mount_folders
>>> app.debug = True

# Ah, snap!
>>> app.test_client().get('/static/app.js')
<Response [404]>

>>> STATICIFY_FOLDERS = (
...    os.path.join(app.root_path, 'tmp'),
...    ('prefix', 'path/to/folder')
>>> )
# Mounting will override the endpoint='static' view function
# to look also into the additional folders as a fallback.
>>> mount_folders(app, STATICIFY_FOLDERS)

# And that's it!
>>> app.test_client().get('/static/app.js')
<Response [200]>

API

mount_folders(app, locations)

A single top-level function where the all magic comes from.

locations

an iterable of strings with the additional static locations. It also accepts a 2-tuple of the form (prefix, folder) and using a prefix is a way to connect specific urls with a folder directly.

Install

$ pip install Flask-Staticify

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-Staticify-0.2.2.tar.gz (2.4 kB view details)

Uploaded Source

File details

Details for the file Flask-Staticify-0.2.2.tar.gz.

File metadata

File hashes

Hashes for Flask-Staticify-0.2.2.tar.gz
Algorithm Hash digest
SHA256 875232c3ff32155f34ad14935a92ebe1c2926325399682f70374af267591a019
MD5 eafe383ee41d98b78d3f2f8f727df403
BLAKE2b-256 70176a03dc1450cdcab714fbcb32ec4fe325b706f3040cbe08f5e67743414224

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