WIP router for Datasette plugins
Project description
datasette-plugin-router
WIP router for Datasette plugins
Datasette plugins that have a lot of custom API endpoints can get tiresome to write by hand. datasette-plugin-router aims to be a small Python library that adds a FastAPI-like API for defining custom Datasette plugin endpoints.
- Define routes with familiar GET/POST decorators
- Define Pydantic-backed input/output schemas on JSON endpoints
register_routes()compatability- export to OpenAPI schema for codegen'ing clients
Sample usage:
from datasette import Response, hookimpl
from datasette_plugin_router import Router, Body
from pydantic import BaseModel
router = Router()
class Input(BaseModel):
id: int
name: str
class Output(BaseModel):
id_negative: int
name_upper: str
@router.POST(r"/-/demo1$", output=Output)
async def demo1(params: Body[Input]) -> Output:
output = Output(
id_negative=-1 * params.id,
name_upper=params.name.upper(),
)
return Response.json(output.model_dump())
@router.GET(r"/-/hello/(?P<name>.*)$")
async def hello(name: str):
return Response.html(f"<h1>Hello, {name}!</h1>")
@hookimpl
def register_routes():
return router.routes()
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_plugin_router-0.0.1a3.tar.gz.
File metadata
- Download URL: datasette_plugin_router-0.0.1a3.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07c091069c644a17402afa9cbed22b50f4c165ed54263a0b07445fb10e6806f9
|
|
| MD5 |
24843b3a2b7eb5afb7d5a282184e34c1
|
|
| BLAKE2b-256 |
c2d58dfceae428c9530f374bd3004158d39524e9f42cc32ad0f01180896b252b
|
Provenance
The following attestation bundles were made for datasette_plugin_router-0.0.1a3.tar.gz:
Publisher:
publish.yml on datasette/datasette-plugin-router
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_plugin_router-0.0.1a3.tar.gz -
Subject digest:
07c091069c644a17402afa9cbed22b50f4c165ed54263a0b07445fb10e6806f9 - Sigstore transparency entry: 1438042096
- Sigstore integration time:
-
Permalink:
datasette/datasette-plugin-router@265cc7cb3c2f15baff28bd618741629c57e5f54c -
Branch / Tag:
refs/tags/0.0.1a3 - Owner: https://github.com/datasette
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@265cc7cb3c2f15baff28bd618741629c57e5f54c -
Trigger Event:
release
-
Statement type:
File details
Details for the file datasette_plugin_router-0.0.1a3-py3-none-any.whl.
File metadata
- Download URL: datasette_plugin_router-0.0.1a3-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9986e78acdad4889f9b3f1af4fc97f6a4e7cb2b4a48f577686463e030323cbc
|
|
| MD5 |
9db7dd2f7ffd2ebba81eaeb7c722f06a
|
|
| BLAKE2b-256 |
1c9df144edeae2b14aa12a9c9c9d97b8c55d0a4aaf578c6b1dc9c1dccc942af4
|
Provenance
The following attestation bundles were made for datasette_plugin_router-0.0.1a3-py3-none-any.whl:
Publisher:
publish.yml on datasette/datasette-plugin-router
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_plugin_router-0.0.1a3-py3-none-any.whl -
Subject digest:
e9986e78acdad4889f9b3f1af4fc97f6a4e7cb2b4a48f577686463e030323cbc - Sigstore transparency entry: 1438042116
- Sigstore integration time:
-
Permalink:
datasette/datasette-plugin-router@265cc7cb3c2f15baff28bd618741629c57e5f54c -
Branch / Tag:
refs/tags/0.0.1a3 - Owner: https://github.com/datasette
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@265cc7cb3c2f15baff28bd618741629c57e5f54c -
Trigger Event:
release
-
Statement type: