Use favicon

This commit is contained in:
Andras Schmelczer 2022-07-09 20:52:29 +02:00
parent 378047e622
commit bf7982c56b
No known key found for this signature in database
GPG key ID: 0EA1BC97D0AB076E
4 changed files with 20 additions and 8 deletions

View file

@ -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)

View file

@ -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:

View file

@ -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 {

View file

@ -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",
),