mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
New request.cookies property
This commit is contained in:
parent
b4cd8797b8
commit
1d0bea157a
3 changed files with 12 additions and 7 deletions
|
|
@ -4,6 +4,7 @@ from mimetypes import guess_type
|
|||
from urllib.parse import parse_qs, urlunparse, parse_qsl
|
||||
from pathlib import Path
|
||||
from html import escape
|
||||
from http.cookies import SimpleCookie
|
||||
import re
|
||||
import aiofiles
|
||||
|
||||
|
|
@ -44,6 +45,12 @@ class Request:
|
|||
def host(self):
|
||||
return self.headers.get("host") or "localhost"
|
||||
|
||||
@property
|
||||
def cookies(self):
|
||||
cookies = SimpleCookie()
|
||||
cookies.load(self.headers.get("cookie", ""))
|
||||
return {key: value.value for key, value in cookies.items()}
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
if self.scope.get("raw_path") is not None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue