Custom Response Classes - File, HTML, Redirect, Streaming, etc.¶
There are several custom response classes you can use to create an instance and return them directly from your path operations.
Read more about it in the FastAPI docs for Custom Response - HTML, Stream, File, others.
You can import them directly from fastapi.responses
:
from fastapi.responses import (
FileResponse,
HTMLResponse,
JSONResponse,
ORJSONResponse,
PlainTextResponse,
RedirectResponse,
Response,
StreamingResponse,
UJSONResponse,
)
FastAPI Responses¶
There are a couple of custom FastAPI response classes, you can use them to optimize JSON performance.
fastapi.responses.UJSONResponse
¶
UJSONResponse(<span data-autorefs-optional="fastapi.responses.UJSONResponse(content)">content</span>, <span data-autorefs-optional="fastapi.responses.UJSONResponse(status_code)">status_code</span>=200, <span data-autorefs-optional="fastapi.responses.UJSONResponse(headers)">headers</span>=None, <span data-autorefs-optional="fastapi.responses.UJSONResponse(media_type)">media_type</span>=None, <span data-autorefs-optional="fastapi.responses.UJSONResponse(background)">background</span>=None)
Bases: JSONResponse
JSON response using the high-performance ujson library to serialize data to JSON.
Read more about it in the FastAPI docs for Custom Response - HTML, Stream, File, others.
PARAMETER | DESCRIPTION |
---|---|
content
|
TYPE:
|
status_code
|
TYPE:
|
headers
|
TYPE:
|
media_type
|
TYPE:
|
background
|
TYPE:
|
Source code in starlette/responses.py
175 176 177 178 179 180 181 182 183 |
|
render
¶
render(<span data-autorefs-optional="fastapi.responses.UJSONResponse.render(content)">content</span>)
PARAMETER | DESCRIPTION |
---|---|
content
|
TYPE:
|
Source code in fastapi/responses.py
31 32 33 |
|
init_headers
¶
init_headers(<span data-autorefs-optional="fastapi.responses.UJSONResponse.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.responses.UJSONResponse.set_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.UJSONResponse.set_cookie(value)">value</span>='', <span data-autorefs-optional="fastapi.responses.UJSONResponse.set_cookie(max_age)">max_age</span>=None, <span data-autorefs-optional="fastapi.responses.UJSONResponse.set_cookie(expires)">expires</span>=None, <span data-autorefs-optional="fastapi.responses.UJSONResponse.set_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.UJSONResponse.set_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.UJSONResponse.set_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.UJSONResponse.set_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.UJSONResponse.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.responses.UJSONResponse.delete_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.UJSONResponse.delete_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.UJSONResponse.delete_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.UJSONResponse.delete_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.UJSONResponse.delete_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.UJSONResponse.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 |
|
fastapi.responses.ORJSONResponse
¶
ORJSONResponse(<span data-autorefs-optional="fastapi.responses.ORJSONResponse(content)">content</span>, <span data-autorefs-optional="fastapi.responses.ORJSONResponse(status_code)">status_code</span>=200, <span data-autorefs-optional="fastapi.responses.ORJSONResponse(headers)">headers</span>=None, <span data-autorefs-optional="fastapi.responses.ORJSONResponse(media_type)">media_type</span>=None, <span data-autorefs-optional="fastapi.responses.ORJSONResponse(background)">background</span>=None)
Bases: JSONResponse
JSON response using the high-performance orjson library to serialize data to JSON.
Read more about it in the FastAPI docs for Custom Response - HTML, Stream, File, others.
PARAMETER | DESCRIPTION |
---|---|
content
|
TYPE:
|
status_code
|
TYPE:
|
headers
|
TYPE:
|
media_type
|
TYPE:
|
background
|
TYPE:
|
Source code in starlette/responses.py
175 176 177 178 179 180 181 182 183 |
|
render
¶
render(<span data-autorefs-optional="fastapi.responses.ORJSONResponse.render(content)">content</span>)
PARAMETER | DESCRIPTION |
---|---|
content
|
TYPE:
|
Source code in fastapi/responses.py
44 45 46 47 48 |
|
init_headers
¶
init_headers(<span data-autorefs-optional="fastapi.responses.ORJSONResponse.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.responses.ORJSONResponse.set_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.ORJSONResponse.set_cookie(value)">value</span>='', <span data-autorefs-optional="fastapi.responses.ORJSONResponse.set_cookie(max_age)">max_age</span>=None, <span data-autorefs-optional="fastapi.responses.ORJSONResponse.set_cookie(expires)">expires</span>=None, <span data-autorefs-optional="fastapi.responses.ORJSONResponse.set_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.ORJSONResponse.set_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.ORJSONResponse.set_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.ORJSONResponse.set_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.ORJSONResponse.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.responses.ORJSONResponse.delete_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.ORJSONResponse.delete_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.ORJSONResponse.delete_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.ORJSONResponse.delete_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.ORJSONResponse.delete_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.ORJSONResponse.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 |
|
Starlette Responses¶
fastapi.responses.FileResponse
¶
FileResponse(<span data-autorefs-optional="fastapi.responses.FileResponse(path)">path</span>, <span data-autorefs-optional="fastapi.responses.FileResponse(status_code)">status_code</span>=200, <span data-autorefs-optional="fastapi.responses.FileResponse(headers)">headers</span>=None, <span data-autorefs-optional="fastapi.responses.FileResponse(media_type)">media_type</span>=None, <span data-autorefs-optional="fastapi.responses.FileResponse(background)">background</span>=None, <span data-autorefs-optional="fastapi.responses.FileResponse(filename)">filename</span>=None, <span data-autorefs-optional="fastapi.responses.FileResponse(stat_result)">stat_result</span>=None, <span data-autorefs-optional="fastapi.responses.FileResponse(method)">method</span>=None, <span data-autorefs-optional="fastapi.responses.FileResponse(content_disposition_type)">content_disposition_type</span>='attachment')
Bases: Response
PARAMETER | DESCRIPTION |
---|---|
path
|
TYPE:
|
status_code
|
TYPE:
|
headers
|
TYPE:
|
media_type
|
TYPE:
|
background
|
TYPE:
|
filename
|
TYPE:
|
stat_result
|
TYPE:
|
method
|
TYPE:
|
content_disposition_type
|
TYPE:
|
Source code in starlette/responses.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
|
render
¶
render(<span data-autorefs-optional="fastapi.responses.FileResponse.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.responses.FileResponse.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.responses.FileResponse.set_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.FileResponse.set_cookie(value)">value</span>='', <span data-autorefs-optional="fastapi.responses.FileResponse.set_cookie(max_age)">max_age</span>=None, <span data-autorefs-optional="fastapi.responses.FileResponse.set_cookie(expires)">expires</span>=None, <span data-autorefs-optional="fastapi.responses.FileResponse.set_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.FileResponse.set_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.FileResponse.set_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.FileResponse.set_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.FileResponse.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.responses.FileResponse.delete_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.FileResponse.delete_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.FileResponse.delete_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.FileResponse.delete_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.FileResponse.delete_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.FileResponse.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 |
|
fastapi.responses.HTMLResponse
¶
HTMLResponse(<span data-autorefs-optional="fastapi.responses.HTMLResponse(content)">content</span>=None, <span data-autorefs-optional="fastapi.responses.HTMLResponse(status_code)">status_code</span>=200, <span data-autorefs-optional="fastapi.responses.HTMLResponse(headers)">headers</span>=None, <span data-autorefs-optional="fastapi.responses.HTMLResponse(media_type)">media_type</span>=None, <span data-autorefs-optional="fastapi.responses.HTMLResponse(background)">background</span>=None)
Bases: Response
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.responses.HTMLResponse.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.responses.HTMLResponse.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.responses.HTMLResponse.set_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.HTMLResponse.set_cookie(value)">value</span>='', <span data-autorefs-optional="fastapi.responses.HTMLResponse.set_cookie(max_age)">max_age</span>=None, <span data-autorefs-optional="fastapi.responses.HTMLResponse.set_cookie(expires)">expires</span>=None, <span data-autorefs-optional="fastapi.responses.HTMLResponse.set_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.HTMLResponse.set_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.HTMLResponse.set_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.HTMLResponse.set_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.HTMLResponse.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.responses.HTMLResponse.delete_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.HTMLResponse.delete_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.HTMLResponse.delete_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.HTMLResponse.delete_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.HTMLResponse.delete_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.HTMLResponse.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 |
|
fastapi.responses.JSONResponse
¶
JSONResponse(<span data-autorefs-optional="fastapi.responses.JSONResponse(content)">content</span>, <span data-autorefs-optional="fastapi.responses.JSONResponse(status_code)">status_code</span>=200, <span data-autorefs-optional="fastapi.responses.JSONResponse(headers)">headers</span>=None, <span data-autorefs-optional="fastapi.responses.JSONResponse(media_type)">media_type</span>=None, <span data-autorefs-optional="fastapi.responses.JSONResponse(background)">background</span>=None)
Bases: Response
PARAMETER | DESCRIPTION |
---|---|
content
|
TYPE:
|
status_code
|
TYPE:
|
headers
|
TYPE:
|
media_type
|
TYPE:
|
background
|
TYPE:
|
Source code in starlette/responses.py
175 176 177 178 179 180 181 182 183 |
|
render
¶
render(<span data-autorefs-optional="fastapi.responses.JSONResponse.render(content)">content</span>)
PARAMETER | DESCRIPTION |
---|---|
content
|
TYPE:
|
Source code in starlette/responses.py
185 186 187 188 189 190 191 192 |
|
init_headers
¶
init_headers(<span data-autorefs-optional="fastapi.responses.JSONResponse.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.responses.JSONResponse.set_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.JSONResponse.set_cookie(value)">value</span>='', <span data-autorefs-optional="fastapi.responses.JSONResponse.set_cookie(max_age)">max_age</span>=None, <span data-autorefs-optional="fastapi.responses.JSONResponse.set_cookie(expires)">expires</span>=None, <span data-autorefs-optional="fastapi.responses.JSONResponse.set_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.JSONResponse.set_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.JSONResponse.set_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.JSONResponse.set_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.JSONResponse.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.responses.JSONResponse.delete_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.JSONResponse.delete_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.JSONResponse.delete_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.JSONResponse.delete_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.JSONResponse.delete_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.JSONResponse.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 |
|
fastapi.responses.PlainTextResponse
¶
PlainTextResponse(<span data-autorefs-optional="fastapi.responses.PlainTextResponse(content)">content</span>=None, <span data-autorefs-optional="fastapi.responses.PlainTextResponse(status_code)">status_code</span>=200, <span data-autorefs-optional="fastapi.responses.PlainTextResponse(headers)">headers</span>=None, <span data-autorefs-optional="fastapi.responses.PlainTextResponse(media_type)">media_type</span>=None, <span data-autorefs-optional="fastapi.responses.PlainTextResponse(background)">background</span>=None)
Bases: Response
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.responses.PlainTextResponse.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.responses.PlainTextResponse.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.responses.PlainTextResponse.set_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.PlainTextResponse.set_cookie(value)">value</span>='', <span data-autorefs-optional="fastapi.responses.PlainTextResponse.set_cookie(max_age)">max_age</span>=None, <span data-autorefs-optional="fastapi.responses.PlainTextResponse.set_cookie(expires)">expires</span>=None, <span data-autorefs-optional="fastapi.responses.PlainTextResponse.set_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.PlainTextResponse.set_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.PlainTextResponse.set_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.PlainTextResponse.set_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.PlainTextResponse.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.responses.PlainTextResponse.delete_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.PlainTextResponse.delete_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.PlainTextResponse.delete_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.PlainTextResponse.delete_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.PlainTextResponse.delete_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.PlainTextResponse.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 |
|
fastapi.responses.RedirectResponse
¶
RedirectResponse(<span data-autorefs-optional="fastapi.responses.RedirectResponse(url)">url</span>, <span data-autorefs-optional="fastapi.responses.RedirectResponse(status_code)">status_code</span>=307, <span data-autorefs-optional="fastapi.responses.RedirectResponse(headers)">headers</span>=None, <span data-autorefs-optional="fastapi.responses.RedirectResponse(background)">background</span>=None)
Bases: Response
PARAMETER | DESCRIPTION |
---|---|
url
|
TYPE:
|
status_code
|
TYPE:
|
headers
|
TYPE:
|
background
|
TYPE:
|
Source code in starlette/responses.py
196 197 198 199 200 201 202 203 204 205 206 |
|
render
¶
render(<span data-autorefs-optional="fastapi.responses.RedirectResponse.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.responses.RedirectResponse.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.responses.RedirectResponse.set_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.RedirectResponse.set_cookie(value)">value</span>='', <span data-autorefs-optional="fastapi.responses.RedirectResponse.set_cookie(max_age)">max_age</span>=None, <span data-autorefs-optional="fastapi.responses.RedirectResponse.set_cookie(expires)">expires</span>=None, <span data-autorefs-optional="fastapi.responses.RedirectResponse.set_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.RedirectResponse.set_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.RedirectResponse.set_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.RedirectResponse.set_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.RedirectResponse.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.responses.RedirectResponse.delete_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.RedirectResponse.delete_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.RedirectResponse.delete_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.RedirectResponse.delete_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.RedirectResponse.delete_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.RedirectResponse.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 |
|
fastapi.responses.Response
¶
Response(<span data-autorefs-optional="fastapi.responses.Response(content)">content</span>=None, <span data-autorefs-optional="fastapi.responses.Response(status_code)">status_code</span>=200, <span data-autorefs-optional="fastapi.responses.Response(headers)">headers</span>=None, <span data-autorefs-optional="fastapi.responses.Response(media_type)">media_type</span>=None, <span data-autorefs-optional="fastapi.responses.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.responses.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.responses.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.responses.Response.set_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.Response.set_cookie(value)">value</span>='', <span data-autorefs-optional="fastapi.responses.Response.set_cookie(max_age)">max_age</span>=None, <span data-autorefs-optional="fastapi.responses.Response.set_cookie(expires)">expires</span>=None, <span data-autorefs-optional="fastapi.responses.Response.set_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.Response.set_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.Response.set_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.Response.set_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.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.responses.Response.delete_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.Response.delete_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.Response.delete_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.Response.delete_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.Response.delete_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.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 |
|
fastapi.responses.StreamingResponse
¶
StreamingResponse(<span data-autorefs-optional="fastapi.responses.StreamingResponse(content)">content</span>, <span data-autorefs-optional="fastapi.responses.StreamingResponse(status_code)">status_code</span>=200, <span data-autorefs-optional="fastapi.responses.StreamingResponse(headers)">headers</span>=None, <span data-autorefs-optional="fastapi.responses.StreamingResponse(media_type)">media_type</span>=None, <span data-autorefs-optional="fastapi.responses.StreamingResponse(background)">background</span>=None)
Bases: Response
PARAMETER | DESCRIPTION |
---|---|
content
|
TYPE:
|
status_code
|
TYPE:
|
headers
|
TYPE:
|
media_type
|
TYPE:
|
background
|
TYPE:
|
Source code in starlette/responses.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
render
¶
render(<span data-autorefs-optional="fastapi.responses.StreamingResponse.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.responses.StreamingResponse.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.responses.StreamingResponse.set_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.StreamingResponse.set_cookie(value)">value</span>='', <span data-autorefs-optional="fastapi.responses.StreamingResponse.set_cookie(max_age)">max_age</span>=None, <span data-autorefs-optional="fastapi.responses.StreamingResponse.set_cookie(expires)">expires</span>=None, <span data-autorefs-optional="fastapi.responses.StreamingResponse.set_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.StreamingResponse.set_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.StreamingResponse.set_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.StreamingResponse.set_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.StreamingResponse.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.responses.StreamingResponse.delete_cookie(key)">key</span>, <span data-autorefs-optional="fastapi.responses.StreamingResponse.delete_cookie(path)">path</span>='/', <span data-autorefs-optional="fastapi.responses.StreamingResponse.delete_cookie(domain)">domain</span>=None, <span data-autorefs-optional="fastapi.responses.StreamingResponse.delete_cookie(secure)">secure</span>=False, <span data-autorefs-optional="fastapi.responses.StreamingResponse.delete_cookie(httponly)">httponly</span>=False, <span data-autorefs-optional="fastapi.responses.StreamingResponse.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 |
|