Skip to content

Commit

Permalink
Documentation for .absolute_url(request, path), refs #1034
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Oct 25, 2020
1 parent 6c9fd4e commit 42f4851
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ HTML page. Set this to 0 to disable truncation.

datasette mydatabase.db --config truncate_cells_html:0

.. _config_force_https_urls:

force_https_urls
~~~~~~~~~~~~~~~~
Expand Down
20 changes: 20 additions & 0 deletions docs/internals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,26 @@ Datasette's flash messaging mechanism allows you to add a message that will be d

You can try out these messages (including the different visual styling of the three message types) using the ``/-/messages`` debugging tool.

.. _datasette_absolute_url:

.absolute_url(request, path)
----------------------------

``request`` - Request
The current Request object

``path`` - string
A path, for example ``/dbname/table.json``

Returns the absolute URL for the given path, including the protocol and host. For example:

.. code-block:: python
absolute_url = datasette.absolute_url(request, "/dbname/table.json")
# Would return "http://localhost:8001/dbname/table.json"
The current request object is used to determine the hostname and protocol that should be used for the returned URL. The :ref:`config_force_https_urls` configuration setting is taken into account.

.. _internals_datasette_client:

datasette.client
Expand Down

0 comments on commit 42f4851

Please sign in to comment.