|
60 | 60 | # add /mosaic/list endpoint
|
61 | 61 | add_mosaic_list=True,
|
62 | 62 | )
|
| 63 | + |
| 64 | + |
| 65 | +@mosaic.router.get("/builder", response_class=HTMLResponse) |
| 66 | +async def mosaic_builder(request: Request): |
| 67 | + """Mosaic Builder Viewer.""" |
| 68 | + return templates.TemplateResponse( |
| 69 | + name="mosaic-builder.html", |
| 70 | + context={ |
| 71 | + "request": request, |
| 72 | + "register_endpoint": mosaic.url_for(request, "register_search"), |
| 73 | + "collections_endpoint": str(request.url_for("list_collection")), |
| 74 | + }, |
| 75 | + media_type="text/html", |
| 76 | + ) |
| 77 | + |
| 78 | + |
| 79 | +# `Secret` endpoint for mosaic builder. Do not need to be public (in the OpenAPI docs) |
| 80 | +@app.get("/collections", include_in_schema=False) |
| 81 | +async def list_collection(request: Request): |
| 82 | + """list collections.""" |
| 83 | + with request.app.state.dbpool.connection() as conn: |
| 84 | + with conn.cursor() as cursor: |
| 85 | + cursor.execute("SELECT * FROM collections;") |
| 86 | + return [t[2] for t in cursor.fetchall() if t] |
| 87 | + |
| 88 | + |
63 | 89 | app.include_router(mosaic.router, tags=["Mosaic"], prefix="/mosaic")
|
64 | 90 |
|
65 | 91 | ###############################################################################
|
@@ -157,6 +183,12 @@ def landing(request: Request):
|
157 | 183 | "type": "application/json",
|
158 | 184 | "rel": "data",
|
159 | 185 | },
|
| 186 | + { |
| 187 | + "title": "Mosaic Builder", |
| 188 | + "href": mosaic.url_for(request, "mosaic_builder"), |
| 189 | + "type": "text/html", |
| 190 | + "rel": "data", |
| 191 | + }, |
160 | 192 | {
|
161 | 193 | "title": "Mosaic Metadata (template URL)",
|
162 | 194 | "href": mosaic.url_for(request, "info_search", searchid="{searchid}"),
|
|
0 commit comments