Response
class¶
You can declare a parameter in a path operation function or dependency to be of type
Response
and then you can set data for the response like headers or cookies.
You can also use it directly to create an instance of it and return it from your path operations.
You can import it directly from fastapi
:
from fastapi import Response
fastapi.Response
¶
Response(<span data-autorefs-optional="fastapi.Response(content)">content</span>=None, <span data-autorefs-optional="fastapi.Response(status_code)">status_code</span>=200, <span data-autorefs-optional="fastapi.Response(headers)">headers</span>=None, <span data-autorefs-optional="fastapi.Response(media_type)">media_type</span>=None, <span data-autorefs-optional="fastapi.Response(background)">background</span>=None)
PARAMETER | DESCRIPTION |
---|---|
content
|
TYPE:
|
status_code
|
TYPE:
|
headers
|
TYPE:
|
media_type
|
TYPE:
|
background
|
TYPE:
|
Source code in starlette/responses.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
render
¶
render(<span data-autorefs-optional="fastapi.Response.render(content)">content</span>)
PARAMETER | DESCRIPTION |
---|---|
content
|
TYPE:
|
Source code in starlette/responses.py
44 45 46 47 48 49 |
|
init_headers
¶
init_headers(<span data-autorefs-optional="fastapi.Response.init_headers(headers)">headers</span>=None)
PARAMETER | DESCRIPTION |
---|---|
headers
|
TYPE:
|
Source code in starlette/responses.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
set_cookie
¶
set_cookie(<span data-autorefs-optional="fastapi.Response.set_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.Response.set_cookie(value)">value</span>='', <span data-autorefs-optional="fastapi.Response.set_cookie(max_age)">max_age</span>=None, <span data-autorefs-optional="fastapi.Response.set_cookie(expires)">expires</span>=None, <span data-autorefs-optional="fastapi.Response.set_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.Response.set_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.Response.set_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.Response.set_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.Response.set_cookie(samesite)">samesite</span>='lax')
PARAMETER | DESCRIPTION |
---|---|
key
|
TYPE:
|
value
|
TYPE:
|
max_age
|
TYPE:
|
expires
|
TYPE:
|
path
|
TYPE:
|
domain
|
TYPE:
|
secure
|
TYPE:
|
httponly
|
TYPE:
|
samesite
|
TYPE:
|
Source code in starlette/responses.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
delete_cookie
¶
delete_cookie(<span data-autorefs-optional="fastapi.Response.delete_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.Response.delete_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.Response.delete_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.Response.delete_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.Response.delete_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.Response.delete_cookie(samesite)">samesite</span>='lax')
PARAMETER | DESCRIPTION |
---|---|
key
|
TYPE:
|
path
|
TYPE:
|
domain
|
TYPE:
|
secure
|
TYPE:
|
httponly
|
TYPE:
|
samesite
|
TYPE:
|
Source code in starlette/responses.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|