-
Is there a way to get a cookie set in a from starlette import status
from starlette.applications import Starlette
from starlette.requests import Request
from starlette.responses import JSONResponse, RedirectResponse
from starlette.routing import Route
from starlette.testclient import TestClient
def home(request: Request):
return JSONResponse({"page": "home"})
def redir_cookie(request: Request):
response = RedirectResponse("/home", status_code=status.HTTP_303_SEE_OTHER)
response.set_cookie("key", "value")
return response
routes = [
Route("/home", home),
Route("/redir_cookie", redir_cookie),
]
app = Starlette(debug=True, routes=routes)
def test_redir_cookie():
print()
with TestClient(app) as client:
response = client.get("/redir_cookie")
print("response:")
print(f" - {response.cookies=}")
print(f" - {response.headers=}") Notes
|
Beta Was this translation helpful? Give feedback.
Answered by
mathause
Apr 4, 2023
Replies: 1 comment
-
The cookie seems to be in |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Kludex
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The cookie seems to be in
response.request.headers
...