UJSONResponse class¶
Warning
The current page still doesn't have a translation for this language.
But you can help translating it: Contributing.
ravyn.responses.encoders.UJSONResponse
¶
UJSONResponse(
content,
status_code=HTTP_200_OK,
headers=None,
media_type=None,
background=None,
encoders=None,
passthrough_body_types=None,
)
Bases: BaseJSONResponse
An alternative to JSONResponse and performance wise, faster.
In the same way the JSONResponse is used, so is the UJSONResponse.
Source code in lilya/responses.py
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
deduce_media_type_from_body
class-attribute
instance-attribute
¶
deduce_media_type_from_body = deduce_media_type_from_body
encoders
instance-attribute
¶
encoders = [
(encoder() if isclass(encoder) else encoder)
for encoder in (encoders or _empty)
]
make_response
¶
make_response(content)
Source code in ravyn/responses/encoders.py
47 48 49 50 51 | |
execute_cleanup_handler
async
¶
execute_cleanup_handler()
Source code in lilya/responses.py
127 128 129 130 131 132 | |
resolve_async_content
async
¶
resolve_async_content()
Source code in lilya/responses.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
find_media_type
¶
find_media_type()
Source code in lilya/responses.py
151 152 153 | |
with_transform_kwargs
classmethod
¶
with_transform_kwargs(params)
Source code in lilya/responses.py
155 156 157 158 159 160 161 162 | |
transform
classmethod
¶
transform(content)
Source code in lilya/responses.py
164 165 166 167 168 169 | |
make_headers
¶
make_headers(content_headers=None)
Initializes the headers based on RFC specifications by setting appropriate conditions and restrictions.
| PARAMETER | DESCRIPTION |
|---|---|
content_headers
|
Additional headers to include (default is None).
TYPE:
|
Source code in lilya/responses.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
set_cookie
¶
set_cookie(
key,
value="",
*,
path="/",
domain=None,
secure=False,
max_age=None,
expires=None,
httponly=False,
samesite="lax",
)
Sets a cookie in the response headers.
| PARAMETER | DESCRIPTION |
|---|---|
key
|
The name of the cookie.
TYPE:
|
value
|
The value of the cookie.
TYPE:
|
path
|
The path for which the cookie is valid (default is '/').
TYPE:
|
domain
|
The domain to which the cookie belongs.
TYPE:
|
secure
|
If True, the cookie should only be sent over HTTPS.
TYPE:
|
max_age
|
The maximum age of the cookie in seconds.
TYPE:
|
expires
|
The expiration date of the cookie.
TYPE:
|
httponly
|
If True, the cookie should only be accessible through HTTP.
TYPE:
|
samesite
|
SameSite attribute of the cookie.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
AssertionError
|
If samesite is not one of 'strict', 'lax', or 'none'. |
Source code in lilya/responses.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
delete_cookie
¶
delete_cookie(
key,
path="/",
domain=None,
secure=False,
httponly=False,
samesite="lax",
)
Deletes a cookie in the response headers by setting its max age and expiration to 0.
| PARAMETER | DESCRIPTION |
|---|---|
key
|
The name of the cookie to delete.
TYPE:
|
path
|
The path for which the cookie is valid (default is '/').
TYPE:
|
domain
|
The domain to which the cookie belongs.
TYPE:
|
secure
|
If True, the cookie should only be sent over HTTPS.
TYPE:
|
httponly
|
If True, the cookie should only be accessible through HTTP.
TYPE:
|
samesite
|
SameSite attribute of the cookie.
TYPE:
|
Source code in lilya/responses.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
message
¶
message(prefix)
Source code in lilya/responses.py
335 336 337 338 339 340 341 | |