Link to Datasette API docs from /-/api, refs #1871

This commit is contained in:
Simon Willison 2022-11-01 22:45:05 -07:00
commit 000eeb4464
3 changed files with 8 additions and 9 deletions

View file

@ -1100,6 +1100,7 @@ class Datasette:
), ),
"base_url": self.setting("base_url"), "base_url": self.setting("base_url"),
"csrftoken": request.scope["csrftoken"] if request else lambda: "", "csrftoken": request.scope["csrftoken"] if request else lambda: "",
"datasette_version": __version__,
}, },
**extra_template_vars, **extra_template_vars,
} }

View file

@ -10,14 +10,13 @@
<h1>API Explorer</h1> <h1>API Explorer</h1>
<p>Use this tool to try out the Datasette write API.</p> <p>Use this tool to try out the
{% if datasette_version %}
{% if errors %} <a href="https://docs.datasette.io/en/{{ datasette_version }}/json_api.html">Datasette API</a>.
{% for error in errors %} {% else %}
<p class="message-error">{{ error }}</p> Datasette API.
{% endfor %} {% endif %}
{% endif %} </p>
<details open style="border: 2px solid #ccc; border-bottom: none; padding: 0.5em"> <details open style="border: 2px solid #ccc; border-bottom: none; padding: 0.5em">
<summary style="cursor: pointer;">GET</summary> <summary style="cursor: pointer;">GET</summary>
<form method="get" id="api-explorer-get" style="margin-top: 0.7em"> <form method="get" id="api-explorer-get" style="margin-top: 0.7em">

View file

@ -507,7 +507,6 @@ class DataView(BaseView):
if key not in ("_labels", "_facet", "_size") if key not in ("_labels", "_facet", "_size")
] ]
+ [("_size", "max")], + [("_size", "max")],
"datasette_version": __version__,
"settings": self.ds.settings_dict(), "settings": self.ds.settings_dict(),
}, },
} }