Add get_query_params method (#244)

This commit is contained in:
Thomas Brandého 2023-01-10 23:09:46 +01:00 committed by GitHub
parent 3708d960de
commit 51a635fe75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -267,7 +267,17 @@ class State(Base, ABC):
Returns:
The current page.
"""
return cls.router_data["pathname"]
return cls.router_data.get("pathname", "")
def get_query_params(cls) -> Dict[str, str]:
"""Obtain the query parameters for the queried page.
The query object contains both the URI parameters and the GET parameters.
Returns:
The dict of query parameters.
"""
return cls.router_data.get("query", {})
def __getattribute__(self, name: str) -> Any:
"""Get the state var.