MCPcopy
hub / github.com/encode/starlette / multi_items_app

Function multi_items_app

tests/test_formparsers.py:54–75  ·  view source on GitHub ↗
(scope: Scope, receive: Receive, send: Send)

Source from the content-addressed store, hash-verified

52
53
54async def multi_items_app(scope: Scope, receive: Receive, send: Send) -> None:
55 request = Request(scope, receive)
56 data = await request.form()
57 output: dict[str, list[Any]] = {}
58 for key, value in data.multi_items():
59 if key not in output:
60 output[key] = []
61 if isinstance(value, UploadFile):
62 content = await value.read()
63 output[key].append(
64 {
65 "filename": value.filename,
66 "size": value.size,
67 "content": content.decode(),
68 "content_type": value.content_type,
69 }
70 )
71 else:
72 output[key].append(value)
73 await request.close()
74 response = JSONResponse(output)
75 await response(scope, receive, send)
76
77
78async def app_with_headers(scope: Scope, receive: Receive, send: Send) -> None:

Callers

nothing calls this directly

Calls 8

formMethod · 0.95
closeMethod · 0.95
RequestClass · 0.90
JSONResponseClass · 0.90
multi_itemsMethod · 0.80
readMethod · 0.80
decodeMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected