mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
datasette.client now applies base_url, closes #1026
This commit is contained in:
parent
7a67bc7a56
commit
84bc7244c1
5 changed files with 56 additions and 13 deletions
|
|
@ -44,6 +44,7 @@ from .url_builder import Urls
|
|||
from .database import Database, QueryInterrupted
|
||||
|
||||
from .utils import (
|
||||
PrefixedUrlString,
|
||||
async_call_with_supported_arguments,
|
||||
await_me_maybe,
|
||||
call_with_supported_arguments,
|
||||
|
|
@ -1242,9 +1243,12 @@ class NotFoundExplicit(NotFound):
|
|||
|
||||
class DatasetteClient:
|
||||
def __init__(self, ds):
|
||||
self.ds = ds
|
||||
self.app = ds.app()
|
||||
|
||||
def _fix(self, path):
|
||||
if not isinstance(path, PrefixedUrlString):
|
||||
path = self.ds.urls.path(path)
|
||||
if path.startswith("/"):
|
||||
path = "http://localhost{}".format(path)
|
||||
return path
|
||||
|
|
|
|||
|
|
@ -387,9 +387,9 @@ class Response:
|
|||
)
|
||||
|
||||
@classmethod
|
||||
def json(cls, body, status=200, headers=None):
|
||||
def json(cls, body, status=200, headers=None, default=None):
|
||||
return cls(
|
||||
json.dumps(body),
|
||||
json.dumps(body, default=default),
|
||||
status=status,
|
||||
headers=headers,
|
||||
content_type="application/json; charset=utf-8",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue