From bf7982c56b32f1eada3cea32647b354f1b067d24 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sat, 9 Jul 2022 20:52:29 +0200 Subject: [PATCH] Use favicon --- great_ai/deploy/routes/bootstrap_dashboard.py | 7 ++++++- great_ai/deploy/routes/bootstrap_docs_endpoints.py | 6 +++++- great_ai/deploy/routes/dashboard/assets/index.css | 13 ++++++++----- great_ai/deploy/routes/dashboard/get_footer.py | 2 +- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/great_ai/deploy/routes/bootstrap_dashboard.py b/great_ai/deploy/routes/bootstrap_dashboard.py index 2a0069a..89b7436 100644 --- a/great_ai/deploy/routes/bootstrap_dashboard.py +++ b/great_ai/deploy/routes/bootstrap_dashboard.py @@ -2,7 +2,7 @@ from pathlib import Path from fastapi import FastAPI from fastapi.middleware.wsgi import WSGIMiddleware -from fastapi.responses import RedirectResponse +from fastapi.responses import FileResponse, RedirectResponse from fastapi.staticfiles import StaticFiles from ...constants import DASHBOARD_PATH @@ -14,6 +14,11 @@ PATH = Path(__file__).parent.resolve() def bootstrap_dashboard(app: FastAPI, function_name: str, documentation: str) -> None: dash_app = create_dash_app(function_name, app.version, documentation) + @app.get("/favicon.ico") + @app.get(f"{DASHBOARD_PATH}/_favicon.ico") + def get_favicon() -> FileResponse: + return FileResponse(PATH / "dashboard/assets/favicon.ico") + app.mount(DASHBOARD_PATH, WSGIMiddleware(dash_app)) @app.get("/", include_in_schema=False) diff --git a/great_ai/deploy/routes/bootstrap_docs_endpoints.py b/great_ai/deploy/routes/bootstrap_docs_endpoints.py index 22fee23..efaaa37 100644 --- a/great_ai/deploy/routes/bootstrap_docs_endpoints.py +++ b/great_ai/deploy/routes/bootstrap_docs_endpoints.py @@ -7,7 +7,11 @@ from starlette.responses import HTMLResponse def bootstrap_docs_endpoints(app: FastAPI) -> None: @app.get("/docs", include_in_schema=False) def custom_swagger_ui_html() -> HTMLResponse: - return get_swagger_ui_html(openapi_url="openapi.json", title=app.title) + return get_swagger_ui_html( + openapi_url="openapi.json", + title=app.title, + swagger_favicon_url="/favicon.ico", + ) @app.get("/docs/index.html", include_in_schema=False) def redirect_to_docs() -> RedirectResponse: diff --git a/great_ai/deploy/routes/dashboard/assets/index.css b/great_ai/deploy/routes/dashboard/assets/index.css index 2241c2b..f4003e7 100644 --- a/great_ai/deploy/routes/dashboard/assets/index.css +++ b/great_ai/deploy/routes/dashboard/assets/index.css @@ -1,5 +1,7 @@ :root { --background-color: #edf5f6; + --dark-background-color: #e7eced; + --light-text-color: #9a9fa0; --small-padding: 10px; --medium-padding: 20px; --large-padding: 40px; @@ -147,7 +149,7 @@ main > header > *:nth-child(2) { } main > header .placeholder { - opacity: 0.35; + color: var(--light-text-color); font-size: 1.5rem; text-align: center; display: block; @@ -205,7 +207,6 @@ main > header .placeholder { } main > footer { - opacity: 0.35; margin: 0; } @@ -214,7 +215,8 @@ main > footer { justify-content: space-between; align-items: center; padding: var(--large-padding); - background-color: #ddd; + background-color: var(--dark-background-color); + color: var(--light-text-color); position: relative; } @@ -225,10 +227,11 @@ main > footer { a img { display: block; margin-left: var(--large-padding); - width: 64px; - height: 64px; + width: 80px; + height: 80px; cursor: pointer; transition: transform 300ms; + opacity: 0.6; } a img:hover { diff --git a/great_ai/deploy/routes/dashboard/get_footer.py b/great_ai/deploy/routes/dashboard/get_footer.py index 0e09328..bdd6d48 100644 --- a/great_ai/deploy/routes/dashboard/get_footer.py +++ b/great_ai/deploy/routes/dashboard/get_footer.py @@ -19,7 +19,7 @@ def get_footer() -> html.Footer: ] ), html.A( - html.Img(src="/assets/github.png"), + html.Img(src="/assets/logo.png"), href=GITHUB_LINK, target="_blank", ),