===================
.. image:: https://travis-ci.org/agx/flask-xstatic-files.svg?branch=master
:target: https://travis-ci.org/agx/flask-xstatic-files
.. highlight:: python
A `Flask`_ extionsion to serve `XStatic`_ files. Can be useful if you
don't use an asset pipeline and want to serve e.g. XStatic packaged
javascript files like `JQuery`_ directly.
Setup
-----
Upon initialization tell Flask about the XStatic modules you want to
use. This example uses JQuery and D3::
app = Flask(__name__)
app.config.from_object(__name__)
app.config.['XSTATIC_MODULES'] = ['jquery', 'd3']
xsf = XStaticFiles(app)
The modules can be given as list or comma separated (``jquery,d3``).
Serving Files
-------------
The extension already installs a route handler for you so files under
``/xstatic/<module>/`` are served automatically. To generate these
URLs you can use ``url_for``::
xsf.url_for('jquery', 'jquery.min.js')
In templates you can use ``xstatic_url_for``:
.. code-block:: html
<script type=text/javascript src="{{ xstatic_url_for(module='jquery', path='jquery.min.js') }}"></script>
to generate these URLs. This has the advantage that you can later
serve files from a static web server by adjusting ``XSTATIC_ROOT`` and
``XSTATIC_PROTO`` without having to modify any code.
In case you want to serve XStatic files from other URLs use ``serve``
or ``serve_or_404``::
@app.route('/somewhere-else/jquery/jquery.min.js')
def serve_jquery():
return xsf.serve_or_404('jquery', 'jquery.min.js')
.. _Flask: http://flask.pocoo.org/
.. _XStatic: https://xstatic.readthedocs.io/en/latest/
.. _JQuery: https://pypi.python.org/pypi/XStatic-jQuery
Metadata
Release files for Flask-XStatic-Files 0.0.2
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 | Actions |
|---|---|---|---|---|
| Flask-XStatic-Files-0.0.2.tar.gz | 3.6 kB | Without provenance | Details for Flask-XStatic-Files-0.0.2.tar.gz |
Release files / Flask-XStatic-Files-0.0.2.tar.gz
| Download URL | Flask-XStatic-Files-0.0.2.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
211e66ea716d972e2af5a446af0abf1c9cf2ed939fddca2da6147038e4707365
|
|
BLAKE2b-256 checksum How to use checksums |
2e70fa321e3d0a02ec93d9d536b214883c3ce1da0720b327d2f15ce1729f1384
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Flask-XStatic-Files 0.0.2
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.