parent
9bc99f796b
commit
befe96257d
1 changed files with 10 additions and 2 deletions
|
|
@ -76,7 +76,11 @@ def create_app(config_object="lnbits.settings") -> FastAPI:
|
||||||
# Only the browser sends "text/html" request
|
# Only the browser sends "text/html" request
|
||||||
# not fail proof, but everything else get's a JSON response
|
# not fail proof, but everything else get's a JSON response
|
||||||
|
|
||||||
if request.headers and "text/html" in request.headers["accept"]:
|
if (
|
||||||
|
request.headers
|
||||||
|
and "accept" in request.headers
|
||||||
|
and "text/html" in request.headers["accept"]
|
||||||
|
):
|
||||||
return template_renderer().TemplateResponse(
|
return template_renderer().TemplateResponse(
|
||||||
"error.html",
|
"error.html",
|
||||||
{"request": request, "err": f"{exc.errors()} is not a valid UUID."},
|
{"request": request, "err": f"{exc.errors()} is not a valid UUID."},
|
||||||
|
|
@ -197,7 +201,11 @@ def register_exception_handlers(app: FastAPI):
|
||||||
traceback.print_exception(etype, err, tb)
|
traceback.print_exception(etype, err, tb)
|
||||||
exc = traceback.format_exc()
|
exc = traceback.format_exc()
|
||||||
|
|
||||||
if request.headers and "text/html" in request.headers["accept"]:
|
if (
|
||||||
|
request.headers
|
||||||
|
and "accept" in request.headers
|
||||||
|
and "text/html" in request.headers["accept"]
|
||||||
|
):
|
||||||
return template_renderer().TemplateResponse(
|
return template_renderer().TemplateResponse(
|
||||||
"error.html", {"request": request, "err": err}
|
"error.html", {"request": request, "err": err}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue