Let Python webservers self-host JS/CSS/etc assets like unpkg does
Project description
Aguirre
Let Python webservers self-host JS/CSS/etc assets like unpkg does
Warning: The utility functions have been proven out, but the integrations have had limited usage. Treat them with caution.
When your Python application needs a Python dependency from PyPI
you can lean on tools like pip
and venv
to manage that.
But what if its a web application that needs a Javascript or
CSS dependency from NPM?
Large applications run by large teams can justify elaborate
build and deployment pipelines.
But a smaller app?
Something internal?
A demo?
Or a learning exercise?
You want a lighter solution...
In recent years it's become popular to lean on unpkg for this. (Or jsdelivr, or cdnjs, or another service.) How easy it is to drop one line into your template and let a CDN look after serving the file to your users:
<script src="https://www.unpkg.com/jquery@3.7.1/dist/jquery.min.js"></script>
But there are disadvantages to relying on a third party like this. It needs to be up whenever your app is up, and be reliable. You are vulnerable to takedowns (remember left-pad?). Your users give up more privacy. And worst of all: you can't develop your application offline.
Aguirre lets you download NPM tarballs and add them to your app. (And probably commit them in too.) Then you can drop a line into your app and let Aguirre serve the desired file straight out of the tarball:
<script src="/pkgs/jquery@3.7.1/dist/jquery.min.js"></script>
Sure, it's not the most scalable solution. But it's a great way to quickly get things moving.
Installation
This code is not currently on PyPI.
Consequently you should add the following line to your
requirements.txt
file:
git+https://github.com/pscl4rke/aguirre.git
Integrations
There are some integrations into frameworks inside
aguirre.integrations
.
Their usage is documented in the module docstrings...
Development and Testing
This codebase uses ephemerun to test against multiple Python versions. (It's a bit like Tox, except is uses containers for isolation rather than virtualenvs.)
Roadmap
- Better Django support
- Handle
pathlib.Path
arguments
Licence
This code is copyright P. S. Clarke and is licensed under the BSD-3-Clause licence.
The test suite contains real-world example files. These are covered by their own embedded licences.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aguirre-0.1.2.tar.gz
.
File metadata
- Download URL: aguirre-0.1.2.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef5fa0a8977f36d9d212258f8bcb88b17d7f1dd87b5475c704f70591e510955a |
|
MD5 | e8a040c1423f2d6ce5279b1e5b73d68f |
|
BLAKE2b-256 | 610f28796a26e730d494d74264d970cec3b841cfacdb9384172e7ba725f40814 |
File details
Details for the file aguirre-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: aguirre-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce899e5e2cd74124f39d807bfbbd91a3c245f67ddff9ff1893a39c181ffe341c |
|
MD5 | a8eb7f57f4b4332f79a9996bae041434 |
|
BLAKE2b-256 | bd0cb233a93ddb67ae47c6476b3c261799daf21a40e215be676288fb5b1e7f45 |