mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Documentation for .absolute_url(request, path), refs #1034
This commit is contained in:
parent
6c9fd4ef1b
commit
42f4851e3e
2 changed files with 21 additions and 0 deletions
|
|
@ -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
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue