mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Include took_ms in JSON output
This commit is contained in:
parent
2a09d37087
commit
c371f06fde
1 changed files with 4 additions and 0 deletions
4
app.py
4
app.py
|
|
@ -11,6 +11,7 @@ import json
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
app_root = Path(__file__).parent
|
app_root = Path(__file__).parent
|
||||||
|
|
||||||
|
|
@ -95,6 +96,7 @@ class BaseView(HTTPMethodView):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
as_json = False
|
as_json = False
|
||||||
extra_template_data = {}
|
extra_template_data = {}
|
||||||
|
start = time.time()
|
||||||
try:
|
try:
|
||||||
data, extra_template_data = self.data(
|
data, extra_template_data = self.data(
|
||||||
request, name, hash, **kwargs
|
request, name, hash, **kwargs
|
||||||
|
|
@ -104,6 +106,8 @@ class BaseView(HTTPMethodView):
|
||||||
'ok': False,
|
'ok': False,
|
||||||
'error': str(e),
|
'error': str(e),
|
||||||
}
|
}
|
||||||
|
end = time.time()
|
||||||
|
data['took_ms'] = (end - start) * 1000
|
||||||
if as_json:
|
if as_json:
|
||||||
# Special case for .jsono extension
|
# Special case for .jsono extension
|
||||||
if as_json == '.jsono':
|
if as_json == '.jsono':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue