change status code
This commit is contained in:
parent
5ceb8639f9
commit
c4f9206c10
1 changed files with 4 additions and 4 deletions
|
|
@ -3,8 +3,9 @@ import importlib
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
import warnings
|
import warnings
|
||||||
|
from http import HTTPStatus
|
||||||
|
|
||||||
from fastapi import FastAPI, Request, status
|
from fastapi import FastAPI, Request
|
||||||
from fastapi.exceptions import RequestValidationError
|
from fastapi.exceptions import RequestValidationError
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.middleware.gzip import GZipMiddleware
|
from fastapi.middleware.gzip import GZipMiddleware
|
||||||
|
|
@ -61,16 +62,15 @@ 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 "text/html" in request.headers["accept"]:
|
if "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."},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
status_code=HTTPStatus.NO_CONTENT,
|
||||||
content={"detail": exc.errors()},
|
content={"detail": exc.errors()},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue