Meta plugin for debugging utilities while using Datasette
Project description
datasette-debug-bar
A generic debug bar for Datasette that other plugins can add items to. The bar is fixed to the bottom-right corner of every page and can be minimized/expanded (state persists in localStorage).
Installation
datasette install datasette-debug-bar
Writing a debug-bar plugin
Any Datasette plugin can add a section to the debug bar by defining a debug_bar_items function at the top level of its module.
API
def debug_bar_items(datasette):
return {
"label": "My Section",
"entrypoint": """function(el) {
// el is an empty HTMLElement — append your UI to it
el.textContent = 'Hello from my plugin!';
}""",
}
| Key | Type | Description |
|---|---|---|
label |
str |
Heading displayed above the section in the bar. |
entrypoint |
str |
A JavaScript function body as a string. It receives a single argument el (an HTMLElement). Append whatever DOM you want to el. |
You can return a single dict or a list of dicts to register multiple sections.
Complete example
Here is a minimal but complete Datasette plugin that adds a "Request Info" section to the debug bar. This is a single Python file that can be used directly with datasette --plugins-dir.
# debug_request_info.py
def debug_bar_items(datasette):
return {
"label": "Request Info",
"entrypoint": """function(el) {
var items = [
['Path', location.pathname],
['Query', location.search || '(none)'],
['Hash', location.hash || '(none)'],
];
var table = document.createElement('table');
table.style.cssText = 'border-collapse:collapse;font-size:12px;width:100%;';
items.forEach(function(row) {
var tr = document.createElement('tr');
var td1 = document.createElement('td');
td1.textContent = row[0];
td1.style.cssText = 'padding:2px 8px 2px 0;color:#666;white-space:nowrap;';
var td2 = document.createElement('td');
td2.textContent = row[1];
td2.style.cssText = 'padding:2px 0;font-family:monospace;word-break:break-all;';
tr.appendChild(td1);
tr.appendChild(td2);
table.appendChild(tr);
});
el.appendChild(table);
}""",
}
Using it as a package
For installable plugins, add datasette-debug-bar as a dependency in your pyproject.toml:
[project]
dependencies = [
"datasette",
"datasette-debug-bar",
]
[project.entry-points.datasette]
my_debug_plugin = "my_debug_plugin"
Then define debug_bar_items in your package's __init__.py. The function will be discovered automatically when both plugins are installed.
Entrypoint tips
- The
elargument is a<div>inside the bar panel. Append DOM nodes to it. - The function runs once on page load. If you need live updates, use
setIntervalor event listeners inside the function. - You have access to the full browser environment:
document,window,fetch,localStorage,location, cookies, etc. - Keep the UI compact — the bar is meant for quick-glance debugging info.
Sample plugins
The sample/ directory contains two working example plugins that can be used with --plugins-dir:
debug_request_info.py— displays current URL path, query string, and hashdebug_performance.py— displays page performance timing (DNS, connect, response, DOM ready, load, transfer size)
Run them:
DATASETTE_SECRET=abc123 datasette --plugins-dir sample
Development
cd datasette-debug-bar
# Run tests
uv run pytest
# Run dev server with sample plugins
just dev
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datasette_debug_bar-0.0.1a1.tar.gz.
File metadata
- Download URL: datasette_debug_bar-0.0.1a1.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5390f656852cf3e3404d625757fc6f27c69be86f3784c7901b87562740085689
|
|
| MD5 |
219abb1532d2acc7cb35b5f6b4617988
|
|
| BLAKE2b-256 |
12fcd72442c1ca1b553f9a24426edf3d0d61eb1048e8b40961d22c9cad79e506
|
Provenance
The following attestation bundles were made for datasette_debug_bar-0.0.1a1.tar.gz:
Publisher:
publish.yml on datasette/datasette-debug-bar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_debug_bar-0.0.1a1.tar.gz -
Subject digest:
5390f656852cf3e3404d625757fc6f27c69be86f3784c7901b87562740085689 - Sigstore transparency entry: 1138584828
- Sigstore integration time:
-
Permalink:
datasette/datasette-debug-bar@3c13f54d7c87fec95b4070fe76f8140daea39407 -
Branch / Tag:
refs/tags/0.0.1a1 - Owner: https://github.com/datasette
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3c13f54d7c87fec95b4070fe76f8140daea39407 -
Trigger Event:
release
-
Statement type:
File details
Details for the file datasette_debug_bar-0.0.1a1-py3-none-any.whl.
File metadata
- Download URL: datasette_debug_bar-0.0.1a1-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee4e70a2beeb1fe65784c81edb81595b5a37075443108041cf7c7da0bf5016f3
|
|
| MD5 |
cd77aa20cffdb2fad271042fe3793ebc
|
|
| BLAKE2b-256 |
e3d8521a72d1611391b9b771dd271c2c806900436e50b2c78ca80748cab66ba4
|
Provenance
The following attestation bundles were made for datasette_debug_bar-0.0.1a1-py3-none-any.whl:
Publisher:
publish.yml on datasette/datasette-debug-bar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_debug_bar-0.0.1a1-py3-none-any.whl -
Subject digest:
ee4e70a2beeb1fe65784c81edb81595b5a37075443108041cf7c7da0bf5016f3 - Sigstore transparency entry: 1138584886
- Sigstore integration time:
-
Permalink:
datasette/datasette-debug-bar@3c13f54d7c87fec95b4070fe76f8140daea39407 -
Branch / Tag:
refs/tags/0.0.1a1 - Owner: https://github.com/datasette
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3c13f54d7c87fec95b4070fe76f8140daea39407 -
Trigger Event:
release
-
Statement type: