Skip to content

Commit 0c29626

Browse files
authored
Merge pull request #12 from FernandoCelmer/fix-issue-11
Fix: Error sending HTTP 204 response in DELETE method
2 parents 72ca002 + 167f65e commit 0c29626

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
from fastapi import FastAPI, Body, HTTPException, status
3-
from fastapi.responses import JSONResponse
3+
from fastapi.responses import Response, JSONResponse
44
from fastapi.encoders import jsonable_encoder
55
from pydantic import BaseModel, Field, EmailStr
66
from bson import ObjectId
@@ -118,6 +118,6 @@ async def delete_student(id: str):
118118
delete_result = await db["students"].delete_one({"_id": id})
119119

120120
if delete_result.deleted_count == 1:
121-
return JSONResponse(status_code=status.HTTP_204_NO_CONTENT)
121+
return Response(status_code=status.HTTP_204_NO_CONTENT)
122122

123123
raise HTTPException(status_code=404, detail=f"Student {id} not found")

0 commit comments

Comments
 (0)