Skip to content

Commit

Permalink
add raster landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Jun 21, 2023
1 parent 6a59ace commit 4fbd61b
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 0 deletions.
88 changes: 88 additions & 0 deletions runtime/eoapi/raster/eoapi/raster/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,94 @@ def ping(
return {"database_online": False}


###############################################################################
# Landing page Endpoint

This comment has been minimized.

Copy link
@vincentsarago

vincentsarago Jun 21, 2023

Author Member
Screenshot 2023-06-21 at 12 47 34 PM
@app.get(
"/",
response_class=HTMLResponse,
)
def landing(request: Request):
"""Get landing page."""
data = {
"title": "eoAPI-Raster",
"links": [
{
"title": "Landing page",
"href": str(request.url_for("landing")),
"type": "text/html",
"rel": "self",
},
{
"title": "the API definition (JSON)",
"href": str(request.url_for("openapi")),
"type": "application/vnd.oai.openapi+json;version=3.0",
"rel": "service-desc",
},
{
"title": "the API documentation",
"href": str(request.url_for("swagger_ui_html")),
"type": "text/html",
"rel": "service-doc",
},
{
"title": "Mosaic List (JSON)",
"href": mosaic.url_for(request, "list_mosaic"),
"type": "application/json",
"rel": "data",
},
{
"title": "Mosaic Metadata (template URL)",
"href": mosaic.url_for(request, "info_search", searchid="{searchid}"),
"type": "application/json",
"rel": "data",
},
{
"title": "Mosaic viewer (template URL)",
"href": mosaic.url_for(request, "map_viewer", searchid="{searchid}"),
"type": "text/html",
"rel": "data",
},
{
"title": "TiTiler-pgSTAC Documentation (external link)",
"href": "https://stac-utils.github.io/titiler-pgstac/",
"type": "text/html",
"rel": "doc",
},
],
}

urlpath = request.url.path
crumbs = []
baseurl = str(request.base_url).rstrip("/")

crumbpath = str(baseurl)
for crumb in urlpath.split("/"):
crumbpath = crumbpath.rstrip("/")
part = crumb
if part is None or part == "":
part = "Home"
crumbpath += f"/{crumb}"
crumbs.append({"url": crumbpath.rstrip("/"), "part": part.capitalize()})

return templates.TemplateResponse(
"landing.html",
{
"request": request,
"response": data,
"template": {
"api_root": baseurl,
"params": request.query_params,
"title": "",
},
"crumbs": crumbs,
"url": str(request.url),
"baseurl": baseurl,
"urlpath": str(request.url.path),
"urlparams": str(request.url.query),
},
)


if settings.cors_origins:
app.add_middleware(
CORSMiddleware,
Expand Down
72 changes: 72 additions & 0 deletions runtime/eoapi/raster/eoapi/raster/templates/landing.html

Large diffs are not rendered by default.

0 comments on commit 4fbd61b

Please sign in to comment.