Skip to main content

Looks for static files in the ad hoc folder as a fallback

Project description

This is a simple extension that helps you to serve static files if they doesn’t exist from the ad hoc folder.

Created to work nicely with Grunt or any other build tools that handle your fancy static files.

Usage

Let’s have an example of compiling CoffeeScript to JavaScript (with grunt-contrib-coffee and grunt-usemin), using .tmp for output dir and the following block:

Please note this file doesn't exist.

<!-- build:js static/optimized.js -->
<script src="/static/app.js">
<!-- endbuild -->

After running compile command: static/app.coffee -> .tmp/app.js. To use compiled file while development mount the.tmp folder to the Flask application :

>>> from flask.ext.staticify import mount_folder
>>> if flask_app.debug:
...     # Mount will monkey the "static" endpoint function
...     # to look also into the .tmp folder as a fallback.
...     mount_folder(flask_app, '.tmp')

>>> flask_app.test_client().get('/static/app.js')
... <Response [200 OK]>

And that’s it!

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.1.1.tar.gz (2.2 kB view hashes)

Uploaded Source

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