mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
register_routes() plugin hook datasette argument, closes #1404
This commit is contained in:
parent
6f1731f305
commit
eccfeb0871
6 changed files with 37 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from datasette import hookimpl
|
||||
from datasette.utils.asgi import Response
|
||||
from functools import wraps
|
||||
import markupsafe
|
||||
import json
|
||||
|
|
@ -167,3 +168,12 @@ def table_actions(datasette, database, table, actor, request):
|
|||
return [{"href": datasette.urls.instance(), "label": label}]
|
||||
|
||||
return inner
|
||||
|
||||
|
||||
@hookimpl
|
||||
def register_routes(datasette):
|
||||
config = datasette.plugin_config("register-route-demo")
|
||||
if not config:
|
||||
return
|
||||
path = config["path"]
|
||||
return [(r"/{}/$".format(path), lambda: Response.text(path.upper()))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue