whatchamacallit
Use web resources the pythonic way, import JavaScript modules like you do with Python modules. Specify Javascript modules, HTML, CSS as bare URLs and rewrite on the fly.
Example
(A) Install the desired package, in this example gridchen
pip install gridchen
(B) From HTML/JavaScript
<!DOCTYPE html>
<h1>Hello World</h1>
<script type="module">
import * as utils from "gridchen/utils.js";
const tm = utils.createTransactionManager();
</script>
(C) Register your FastAPI app (see also module whatchamacallit.examples.fastapi_server.py)
from fastapi import FastAPI
from whatchamacallit.fastapi import register
app = FastAPI()
register(app)
or Flask app (see also module whatchamacallit.examples.flask_server.py)
import flask
from whatchamacallit.flask import register
# Important: Do not use the evil static_url_path
app = flask.Flask(__name__, static_folder=None)
register(app)
Working
Ultimately, the import * as utils from "gridchen/utils.js" must be mapped to its physical location, for example
/C/projects/myproject/venv/Lib/site-packages/gridchen/utils.js.
This is done in two steps.
Remap bare import specifier
The import * as utils from "gridchen/utils.js" is not valid JavaScript. So at HTML/JavaScript load time the
import is remapped to import * as utils from "/@gridchen/utils.js"
Route resource to Python module
When the server now gets the request for /@gridchen/utils.js, then it resolves to the package gridchen
and serve its resource utils.js.
Contribute
Package
vi setup.py
git commit . -m'bumped version'
git tag x.y.z
git push & git push --tags
python setup.py sdist bdist_wheel
## Publishing
````shell script
python -m twine upload dist/*
Previous Work
Bundlers
Unpkg.com, rollup, webpack, babel, pika, assetgraph, Browserify, gulp, JSPM
In Place Handlers
References
- http://dplatz.de/blog/2019/es6-bare-imports.html
- https://jakearchibald.com/2017/es-modules-in-browsers/
- https://medium.com/@dmnsgn/in-2020-go-bundler-free-eb29c1f05fc9
- https://wicg.github.io/import-maps/
- https://medium.com/@dmnsgn/es-modules-in-the-browser-almost-now-3638ffafdc68
- https://github.com/fanstatic/fanstatic
- Packages on PyPI starting with js.
Metadata
Release files for whatchamacallit 0.0.6
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 |
|---|---|---|---|---|
| whatchamacallit-0.0.6.tar.gz | 7.7 kB | Without provenance | Details for whatchamacallit-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| whatchamacallit-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for whatchamacallit-0.0.6-py3-none-any.whl |
Total release size: 16.9 kB
Release files / whatchamacallit-0.0.6.tar.gz
| Download URL | whatchamacallit-0.0.6.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95d79d5328d5963cad4bc0c6e4e9f9d845381b4b3769546e5916741fc6c8af45
|
|
BLAKE2b-256 checksum How to use checksums |
00585a65df2dff1baf3fab0198cf63cd8934fa9b5a8b588f840985ef1bba6630
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6
|
Release files / whatchamacallit-0.0.6-py3-none-any.whl
| Download URL | whatchamacallit-0.0.6-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
efde1a90d59e5ec4987aac85847b5bd9aa1038577df50a03c8364f0fa7ed1a6c
|
|
BLAKE2b-256 checksum How to use checksums |
256cdb03fc9c3ccdb12d9e71f7665f04af33c0b70dd98bd39228dfd8915f8d5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6
|
Security for whatchamacallit 0.0.6
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.