11"""app."""
22
3- import re
4-
53import jinja2
64import rasterio
75from fastapi import FastAPI
108from starlette .responses import HTMLResponse
119from starlette .templating import Jinja2Templates
1210from starlette_cramjam .middleware import CompressionMiddleware
11+
1312from titiler .core import __version__ as titiler_version
1413from titiler .core .errors import DEFAULT_STATUS_CODES , add_exception_handlers
1514from titiler .core .factory import AlgorithmFactory , ColorMapFactory , TMSFactory
1615from titiler .core .middleware import CacheControlMiddleware
1716from titiler .xarray .extensions import VariablesExtension
1817from titiler .xarray .factory import TilerFactory
1918
20-
2119from .extensions import DimsExtension
2220from .settings import ApiSettings
2321
3937
4038
4139md = TilerFactory (
42- router_prefix = "/md" ,
4340 extensions = [
4441 VariablesExtension (),
4542 DimsExtension (),
4643 ],
4744)
48- app .include_router (md .router , prefix = "/md" , tags = ["Multi Dimensional" ])
45+ app .include_router (md .router , tags = ["Multi Dimensional" ])
4946
5047# TileMatrixSets endpoints
5148app .include_router (TMSFactory ().router , tags = ["Tiling Schemes" ])
@@ -136,12 +133,16 @@ def landing(request: Request):
136133 }
137134
138135 urlpath = request .url .path
139- if root_path := request .app .root_path :
140- urlpath = re .sub (r"^" + root_path , "" , urlpath )
136+ if root_path := request .scope .get ("root_path" ):
137+ urlpath = urlpath .removeprefix (root_path )
138+
141139 crumbs = []
142140 baseurl = str (request .base_url ).rstrip ("/" )
143141
144142 crumbpath = str (baseurl )
143+ if urlpath == "/" :
144+ urlpath = ""
145+
145146 for crumb in urlpath .split ("/" ):
146147 crumbpath = crumbpath .rstrip ("/" )
147148 part = crumb
@@ -161,13 +162,10 @@ def landing(request: Request):
161162 "title" : "TiTiler" ,
162163 },
163164 "crumbs" : crumbs ,
164- "url" : str (request .url ),
165- "baseurl" : baseurl ,
166- "urlpath" : str (request .url .path ),
167- "urlparams" : str (request .url .query ),
168165 },
169166 )
170167
168+
171169@app .get (
172170 "/healthz" ,
173171 description = "Health Check." ,
0 commit comments