I believe Starlette needs a feature like Flask’s request.values. #2978
Answered
by
Kludex
PowerWordTree
asked this question in
Ideas
-
I believe Starlette needs a feature like Flask’s request.values. async def parse_params(request: Request) -> dict[str, Any]:
result = {}
await request.body()
with contextlib.suppress(Exception):
query_params = request.query_params
for name in query_params.keys():
param = query_params.getlist(name)
result[name] = param[0] if len(param) == 1 else param
content_type = request.headers.get("content-type", "").lower()
if FORM_ENCODE in content_type or FORM_MULTI in content_type:
form_params = await request.form()
for name in form_params.keys():
param = form_params.getlist(name)
result[name] = param[0] if len(param) == 1 else param
elif APP_JSON in content_type:
json_params = await request.json()
if isinstance(json_params, dict):
result.update(json_params)
return result |
Beta Was this translation helpful? Give feedback.
Answered by
Kludex
Aug 7, 2025
Replies: 1 comment 2 replies
-
What does the |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think adding this feature would actually cause more confusion to the current users than the confusion you mention.