From 745b7872b8bd141698db9631a815a4efffefc777 Mon Sep 17 00:00:00 2001
From: Alex Garcia
" in accumulated_body: - extra = escape(json.dumps(trace_info, indent=2)) - extra_html = f"
{extra}".encode() - accumulated_body = accumulated_body.replace(b"", extra_html) - elif "json" in content_type and accumulated_body.startswith(b"{"): - data = json.loads(accumulated_body.decode("utf8")) - if "_trace" not in data: - data["_trace"] = trace_info - accumulated_body = json.dumps(data).encode("utf8") - await send({"type": "http.response.body", "body": accumulated_body}) - - with capture_traces(traces): - await self.app(scope, receive, wrapped_send) diff --git a/datasette/views/base.py b/datasette/views/base.py index 48108cec..d8340fc4 100644 --- a/datasette/views/base.py +++ b/datasette/views/base.py @@ -3,7 +3,6 @@ import hashlib import sys from datasette.utils import ( - EscapeHtmlWriter, InvalidSql, LimitedWriter, add_cors_headers, @@ -225,26 +224,11 @@ async def stream_csv(datasette, fetch_data, request, database): headings.append(f"{column}_label") content_type = "text/plain; charset=utf-8" - preamble = "" - postamble = "" - - trace = request.args.get("_trace") - if trace: - content_type = "text/html; charset=utf-8" - preamble = ( - "
" - '