diff --git a/CHANGES.md b/CHANGES.md index a67e29dd2..a37c64868 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,19 @@ # Release Notes +## Unreleased + +### titiler.core + +* fix template loading for starlette >= 0.28 by using `jinja2.Environment` argument + +### titiler.extensions + +* fix template loading for starlette >= 0.28 by using `jinja2.Environment` argument + +### titiler.application + +* fix template loading for starlette >= 0.28 by using `jinja2.Environment` argument + ## 0.15.7 (2024-01-08) ### titiler.core diff --git a/src/titiler/application/titiler/application/main.py b/src/titiler/application/titiler/application/main.py index 8e81fddca..e85fdf180 100644 --- a/src/titiler/application/titiler/application/main.py +++ b/src/titiler/application/titiler/application/main.py @@ -40,10 +40,10 @@ logging.getLogger("botocore.utils").disabled = True logging.getLogger("rio-tiler").setLevel(logging.ERROR) -templates = Jinja2Templates( - directory="", - loader=jinja2.ChoiceLoader([jinja2.PackageLoader(__package__, "templates")]), -) # type:ignore +jinja2_env = jinja2.Environment( + loader=jinja2.ChoiceLoader([jinja2.PackageLoader(__package__, "templates")]) +) +templates = Jinja2Templates(env=jinja2_env) api_settings = ApiSettings() @@ -56,7 +56,8 @@ def validate_access_token(access_token: str = Security(api_key_query)): """Validates API key access token, set as the `api_settings.global_access_token` value. Returns True if no access token is required, or if the access token is valid. - Raises an HTTPException (401) if the access token is required but invalid/missing.""" + Raises an HTTPException (401) if the access token is required but invalid/missing. + """ if api_settings.global_access_token is None: return True diff --git a/src/titiler/core/pyproject.toml b/src/titiler/core/pyproject.toml index 81cdb8c44..745728746 100644 --- a/src/titiler/core/pyproject.toml +++ b/src/titiler/core/pyproject.toml @@ -29,7 +29,7 @@ classifiers = [ ] dynamic = ["version"] dependencies = [ - "fastapi>=0.100.0,<0.107.0", + "fastapi>=0.107.0", "geojson-pydantic>=1.0,<2.0", "jinja2>=2.11.2,<4.0.0", "numpy", diff --git a/src/titiler/core/titiler/core/factory.py b/src/titiler/core/titiler/core/factory.py index 8ce191498..e3295f58f 100644 --- a/src/titiler/core/titiler/core/factory.py +++ b/src/titiler/core/titiler/core/factory.py @@ -70,11 +70,10 @@ from titiler.core.routing import EndpointScope from titiler.core.utils import render_image -DEFAULT_TEMPLATES = Jinja2Templates( - directory="", - loader=jinja2.ChoiceLoader([jinja2.PackageLoader(__package__, "templates")]), -) # type:ignore - +jinja2_env = jinja2.Environment( + loader=jinja2.ChoiceLoader([jinja2.PackageLoader(__package__, "templates")]) +) +DEFAULT_TEMPLATES = Jinja2Templates(env=jinja2_env) img_endpoint_params: Dict[str, Any] = { "responses": { diff --git a/src/titiler/extensions/titiler/extensions/viewer.py b/src/titiler/extensions/titiler/extensions/viewer.py index cdd14192b..48838de12 100644 --- a/src/titiler/extensions/titiler/extensions/viewer.py +++ b/src/titiler/extensions/titiler/extensions/viewer.py @@ -9,10 +9,10 @@ from titiler.core.factory import BaseTilerFactory, FactoryExtension -DEFAULT_TEMPLATES = Jinja2Templates( - directory="", - loader=jinja2.ChoiceLoader([jinja2.PackageLoader(__package__, "templates")]), -) # type:ignore +jinja2_env = jinja2.Environment( + loader=jinja2.ChoiceLoader([jinja2.PackageLoader(__package__, "templates")]) +) +DEFAULT_TEMPLATES = Jinja2Templates(env=jinja2_env) @dataclass diff --git a/src/titiler/extensions/titiler/extensions/wms.py b/src/titiler/extensions/titiler/extensions/wms.py index 76fc37ab1..6b59ed2a0 100644 --- a/src/titiler/extensions/titiler/extensions/wms.py +++ b/src/titiler/extensions/titiler/extensions/wms.py @@ -22,10 +22,10 @@ from titiler.core.resources.enums import ImageType, MediaType from titiler.core.utils import render_image -DEFAULT_TEMPLATES = Jinja2Templates( - directory="", - loader=jinja2.ChoiceLoader([jinja2.PackageLoader(__package__, "templates")]), -) # type:ignore +jinja2_env = jinja2.Environment( + loader=jinja2.ChoiceLoader([jinja2.PackageLoader(__package__, "templates")]) +) +DEFAULT_TEMPLATES = Jinja2Templates(env=jinja2_env) class WMSMediaType(str, Enum): @@ -522,7 +522,6 @@ def _reader(src_path: str): return image, format, transparent if request_type.lower() == "getmap": - # List of required parameters (styles and crs are excluded) req_keys = { "version",