Skip to content

Commit 58ad02f

Browse files
committed
fix status code make_response
1 parent 6294609 commit 58ad02f

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

dash/backends/_fastapi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,14 @@ def make_response(
310310
data: str | bytes | bytearray,
311311
mimetype: str | None = None,
312312
content_type: str | None = None,
313+
status: int | None = None,
313314
):
314315
headers = {}
315316
if mimetype:
316317
headers["content-type"] = mimetype
317318
if content_type:
318319
headers["content-type"] = content_type
319-
return Response(content=data, headers=headers)
320+
return Response(content=data, headers=headers, status_code=status or 200)
320321

321322
def jsonify(self, obj: Any):
322323
return JSONResponse(content=obj)

dash/backends/_flask.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,11 @@ def make_response(
145145
data: str | bytes | bytearray,
146146
mimetype: str | None = None,
147147
content_type: str | None = None,
148+
status: int | None = None,
148149
):
149-
return Response(data, mimetype=mimetype, content_type=content_type)
150+
return Response(
151+
data, mimetype=mimetype, content_type=content_type, status=status
152+
)
150153

151154
def jsonify(self, obj: Any):
152155
return jsonify(obj)

dash/backends/_quart.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,13 @@ def make_response(
200200
data: str | bytes | bytearray,
201201
mimetype: str | None = None,
202202
content_type: str | None = None,
203+
status=None,
203204
):
204205
if Response is None:
205206
raise RuntimeError("Quart not installed; cannot generate Response")
206-
return Response(data, mimetype=mimetype, content_type=content_type)
207+
return Response(
208+
data, mimetype=mimetype, content_type=content_type, status=status
209+
)
207210

208211
def jsonify(self, obj):
209212
return jsonify(obj)

dash/backends/base_server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ def run(
132132

133133
@abstractmethod
134134
def make_response(
135-
self, data, mimetype=None, content_type=None
135+
self,
136+
data,
137+
mimetype=None,
138+
content_type=None,
139+
status=None,
136140
) -> Any: # pragma: no cover - interface
137141
pass
138142

0 commit comments

Comments
 (0)