'datasette --get' option, closes #926

Also made a start on the datasette.utils.testing module, refs #898
This commit is contained in:
Simon Willison 2020-08-11 17:24:40 -07:00 committed by GitHub
commit e139a7619f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 242 additions and 160 deletions

View file

@ -33,6 +33,9 @@ Options:
cookies
--root Output URL that sets a cookie authenticating the root user
--get TEXT Run an HTTP GET request against this path, print results and
exit
--version-note TEXT Additional note to show on /-/versions
--help-config Show available config options
--help Show this message and exit.

View file

@ -9,7 +9,7 @@ The best way to experience Datasette for the first time is with a demo:
* `fivethirtyeight.datasettes.com <https://fivethirtyeight.datasettes.com/fivethirtyeight>`__ shows Datasette running against over 400 datasets imported from the `FiveThirtyEight GitHub repository <https://github.com/fivethirtyeight/data>`__.
* `sf-trees.datasettes.com <https://sf-trees.datasettes.com/trees/Street_Tree_List>`__ demonstrates the `datasette-cluster-map <https://github.com/simonw/datasette-cluster-map>`__ plugin running against 190,000 trees imported from `data.sfgov.org <https://data.sfgov.org/City-Infrastructure/Street-Tree-List/tkzw-k3nq>`__.
.. _glitch:
.. _getting_started_glitch:
Try Datasette without installing anything using Glitch
------------------------------------------------------
@ -33,6 +33,8 @@ Need some data? Try this `Public Art Data <https://data.seattle.gov/Community/Pu
For more on how this works, see `Running Datasette on Glitch <https://simonwillison.net/2019/Apr/23/datasette-glitch/>`__.
.. _getting_started_your_computer:
Using Datasette on your own computer
------------------------------------
@ -40,13 +42,11 @@ First, follow the :ref:`installation` instructions. Now you can run Datasette ag
::
datasette serve path/to/database.db
datasette path/to/database.db
This will start a web server on port 8001 - visit http://localhost:8001/
to access the web interface.
``serve`` is the default subcommand, you can omit it if you like.
Use Chrome on OS X? You can run datasette against your browser history
like so:
@ -90,7 +90,7 @@ JSON:
}
http://localhost:8001/History/downloads.json?_shape=objects will return that data as
JSON in a more convenient but less efficient format:
JSON in a more convenient format:
::
@ -109,7 +109,57 @@ JSON in a more convenient but less efficient format:
]
}
datasette serve options
-----------------------
.. _getting_started_datasette_get:
datasette --get
---------------
The ``--get`` option can specify the path to a page within Datasette and cause Datasette to output the content from that path without starting the web server. This means that all of Datasette's functionality can be accessed directly from the command-line. For example::
$ datasette --get '/-/versions.json' | jq .
{
"python": {
"version": "3.8.5",
"full": "3.8.5 (default, Jul 21 2020, 10:48:26) \n[Clang 11.0.3 (clang-1103.0.32.62)]"
},
"datasette": {
"version": "0.46+15.g222a84a.dirty"
},
"asgi": "3.0",
"uvicorn": "0.11.8",
"sqlite": {
"version": "3.32.3",
"fts_versions": [
"FTS5",
"FTS4",
"FTS3"
],
"extensions": {
"json1": null
},
"compile_options": [
"COMPILER=clang-11.0.3",
"ENABLE_COLUMN_METADATA",
"ENABLE_FTS3",
"ENABLE_FTS3_PARENTHESIS",
"ENABLE_FTS4",
"ENABLE_FTS5",
"ENABLE_GEOPOLY",
"ENABLE_JSON1",
"ENABLE_PREUPDATE_HOOK",
"ENABLE_RTREE",
"ENABLE_SESSION",
"MAX_VARIABLE_NUMBER=250000",
"THREADSAFE=1"
]
}
}
.. _getting_started_serve_help:
datasette serve --help
----------------------
Running ``datasette downloads.db`` executes the default ``serve`` sub-command, and is equivalent to running ``datasette serve downloads.db``. The full list of options to that command is shown below.
.. literalinclude:: datasette-serve-help.txt

View file

@ -23,7 +23,7 @@ Datasette is a tool for exploring and publishing data. It helps people take data
Datasette is aimed at data journalists, museum curators, archivists, local governments and anyone else who has data that they wish to share with the world. It is part of a :ref:`wider ecosystem of tools and plugins <ecosystem>` dedicated to making working with structured data as productive as possible.
`Explore a demo <https://fivethirtyeight.datasettes.com/fivethirtyeight>`__, watch `a presentation about the project <https://static.simonwillison.net/static/2018/pybay-datasette/>`__ or :ref:`glitch`.
`Explore a demo <https://fivethirtyeight.datasettes.com/fivethirtyeight>`__, watch `a presentation about the project <https://static.simonwillison.net/static/2018/pybay-datasette/>`__ or :ref:`getting_started_glitch`.
More examples: https://github.com/simonw/datasette/wiki/Datasettes

View file

@ -5,7 +5,7 @@
==============
.. note::
If you just want to try Datasette out you don't need to install anything: see :ref:`glitch`
If you just want to try Datasette out you don't need to install anything: see :ref:`getting_started_glitch`
There are two main options for installing Datasette. You can install it directly
on to your machine, or you can install it using Docker.