Periodically refresh Datasette metadata from a remote URL
Project description
datasette-remote-metadata
Periodically refresh Datasette metadata from a remote URL
Installation
Install this plugin in the same environment as Datasette.
$ datasette install datasette-remote-metadata
Usage
Add the following to your metadata.json
:
{
"plugins": {
"datasette-remote-metadata": {
"url": "https://example.com/remote-metadata.yml"
}
}
}
The plugin will fetch the specified metadata from that URL at startup and combine it with any existing metadata. You can use a URL to either a JSON file or a YAML file.
It will periodically refresh that metadata - by default every 30 seconds, unless you specify an alternative "ttl"
value in the plugin configuration.
Configuration
Available configuration options are as follows:
"url"
- the URL to retrieve remote metadata from. Can link to a JSON or a YAML file."ttl"
- integer value in secords: how frequently should the script check for fresh metadata. Defaults to 30 seconds."headers"
- a dictionary of additional request headers to send."cachebust"
- if true, a random?0.29508
value will be added to the query string of the remote metadata to bust any intermediary caches.
This example metadata.json
configuration refreshes every 10 seconds, uses cache busting and sends an Authorization: Bearer xyz
header with the request:
{
"plugins": {
"datasette-remote-metadata": {
"url": "https://example.com/remote-metadata.yml",
"ttl": 10,
"cachebust": true,
"headers": {
"Authorization": "Bearer xyz"
}
}
}
}
This example if you are using metadata.yaml
for configuration:
plugins:
datasette-remote-metadata:
url: https://example.com/remote-metadata.yml
ttl: 10
cachebust: true
headers:
Authorization: Bearer xyz
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-remote-metadata
python3 -mvenv venv
source venv/bin/activate
Or if you are using pipenv
:
pipenv shell
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest
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 datasette-remote-metadata-0.1.tar.gz
.
File metadata
- Download URL: datasette-remote-metadata-0.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaa2a2205eb700cfcfbb342813d1a454208e221324b5cee09cb686b03314a046 |
|
MD5 | 4e4107ede97b01fb6828ddc8fa618641 |
|
BLAKE2b-256 | eb9c4f9fb6d35732958af98566cdfbdf3b965e820b47e03d3bc88432faf310da |
File details
Details for the file datasette_remote_metadata-0.1-py3-none-any.whl
.
File metadata
- Download URL: datasette_remote_metadata-0.1-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1c41cf3b836ae44105d8f86ad989f672209603b20f76c2dcaca92082a6eff4a |
|
MD5 | 0e612bb74441432aae59511b88c86234 |
|
BLAKE2b-256 | 4bea9a92446ead3ec6baf8921515533a6067f31bc41ff525935eda6e4c81454d |