Skip to main content

Utilities for using XStatic in Tornado applications

XStatic is a means of packaging static files, especially JS libraries, for Python applications. Tornado is a Python web framework.

This integration provides:

  • XStaticFileHandler to serve static files from XStatic packages.

  • xstatic_url ui method to build URLs for XStatic files, including the ?v=... tag that Tornado uses for cache invalidation.

To use these:

import tornado.ioloop
import tornado.web
from tornado_xstatic import XStaticFileHandler, xstatic_url

class MyHandler(tornado.web.RequestHandler):
    def get(self):
        self.render("mytemplate.html")


if __name__ == "__main__":
    application = tornado.web.Application(
        [
            (r"/", MyHandler),
            (r"/xstatic/(.*)", XStaticFileHandler,
                {"allowed_modules": ["jquery", "bootstrap"]}),
        ],
        ui_methods={'xstatic_url': xstatic_url('/xstatic/')}
    )
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()

Passing allowed_modules is optional: if it is not provided, files from any XStatic module may be served.

In your template, you can then do this:

<script src="{{ xstatic_url('jquery', 'jquery.min.js') }}"></script>
<script src="{{ xstatic_url('bootstrap', 'js/bootstrap.min.js') }}"></script>

<link href="{{ xstatic_url('bootstrap', 'css/bootstrap.min.css') }}" rel="stylesheet">

Metadata

Release files for tornado_xstatic 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tornado_xstatic 0.3
File Size Uploaded Provenance Actions
tornado_xstatic-0.3.tar.gz 4.3 kB Without provenance Details for tornado_xstatic-0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tornado_xstatic 0.3
File Interpreter ABI Platform Actions
tornado_xstatic-0.3-py3-none-any.whl Python 3 none any Details for tornado_xstatic-0.3-py3-none-any.whl

Total release size: 8.5 kB

Release files / tornado_xstatic-0.3.tar.gz

Download URL tornado_xstatic-0.3.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c1dea4f690886c563d4be9baf03cc0eeb548eb0648436872d8365cf02edd9f2a
BLAKE2b-256 checksum
How to use checksums
8d85368b4f9ad0708e9a56a35903d5fbd43473dc1f69bab7bbbe342f3808adb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.27.0

Release files / tornado_xstatic-0.3-py3-none-any.whl

Download URL tornado_xstatic-0.3-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
29aac34f77105275a9dcf75ef7ee7ead0458596758fc63bbc0f256a33b5ab15a
BLAKE2b-256 checksum
How to use checksums
6774b3c035bc1c0cf05ebf4c2c783426de0f8a325a02690e4a9148bf58a5d777
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.27.0

Security for tornado_xstatic 0.3

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.

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page