-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Closed
Labels
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google "How to X in FastAPI" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
from fastapi import FastAPI, Request, Response
from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
class Middleware(BaseHTTPMiddleware):
async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) -> Response:
await request.json()
response = await call_next(request)
return response
app = FastAPI()
app.add_middleware(Middleware)
@app.post("/test")
async def test(test: dict) -> dict:
return {"data": "test"}Description
- Run script with:
uvicorn main:app --reload - Run CURL with POST request:
curl -X 'POST' 'http://localhost:8000/test' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"test": "test"}'
The application keeps hanging indefinitely and don't send a response to the request. I tested the equivalent code using app = Starlette() and it answers correctly.
Operating System
Linux
Operating System Details
Ubuntu 22.04
FastAPI Version
0.79.0
Python Version
Python 3.10.4
Additional Context
No response
Reactions are currently unavailable