Skip to content

Commit 4fbd61b

Browse files
committed
add raster landing page
1 parent 6a59ace commit 4fbd61b

File tree

2 files changed

+160
-0
lines changed

2 files changed

+160
-0
lines changed

runtime/eoapi/raster/eoapi/raster/app.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,94 @@ def ping(
122122
return {"database_online": False}
123123

124124

125+
###############################################################################
126+
# Landing page Endpoint
127+
@app.get(
128+
"/",
129+
response_class=HTMLResponse,
130+
)
131+
def landing(request: Request):
132+
"""Get landing page."""
133+
data = {
134+
"title": "eoAPI-Raster",
135+
"links": [
136+
{
137+
"title": "Landing page",
138+
"href": str(request.url_for("landing")),
139+
"type": "text/html",
140+
"rel": "self",
141+
},
142+
{
143+
"title": "the API definition (JSON)",
144+
"href": str(request.url_for("openapi")),
145+
"type": "application/vnd.oai.openapi+json;version=3.0",
146+
"rel": "service-desc",
147+
},
148+
{
149+
"title": "the API documentation",
150+
"href": str(request.url_for("swagger_ui_html")),
151+
"type": "text/html",
152+
"rel": "service-doc",
153+
},
154+
{
155+
"title": "Mosaic List (JSON)",
156+
"href": mosaic.url_for(request, "list_mosaic"),
157+
"type": "application/json",
158+
"rel": "data",
159+
},
160+
{
161+
"title": "Mosaic Metadata (template URL)",
162+
"href": mosaic.url_for(request, "info_search", searchid="{searchid}"),
163+
"type": "application/json",
164+
"rel": "data",
165+
},
166+
{
167+
"title": "Mosaic viewer (template URL)",
168+
"href": mosaic.url_for(request, "map_viewer", searchid="{searchid}"),
169+
"type": "text/html",
170+
"rel": "data",
171+
},
172+
{
173+
"title": "TiTiler-pgSTAC Documentation (external link)",
174+
"href": "https://stac-utils.github.io/titiler-pgstac/",
175+
"type": "text/html",
176+
"rel": "doc",
177+
},
178+
],
179+
}
180+
181+
urlpath = request.url.path
182+
crumbs = []
183+
baseurl = str(request.base_url).rstrip("/")
184+
185+
crumbpath = str(baseurl)
186+
for crumb in urlpath.split("/"):
187+
crumbpath = crumbpath.rstrip("/")
188+
part = crumb
189+
if part is None or part == "":
190+
part = "Home"
191+
crumbpath += f"/{crumb}"
192+
crumbs.append({"url": crumbpath.rstrip("/"), "part": part.capitalize()})
193+
194+
return templates.TemplateResponse(
195+
"landing.html",
196+
{
197+
"request": request,
198+
"response": data,
199+
"template": {
200+
"api_root": baseurl,
201+
"params": request.query_params,
202+
"title": "",
203+
},
204+
"crumbs": crumbs,
205+
"url": str(request.url),
206+
"baseurl": baseurl,
207+
"urlpath": str(request.url.path),
208+
"urlparams": str(request.url.query),
209+
},
210+
)
211+
212+
125213
if settings.cors_origins:
126214
app.add_middleware(
127215
CORSMiddleware,

runtime/eoapi/raster/eoapi/raster/templates/landing.html

Lines changed: 72 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)