Use favicon
This commit is contained in:
parent
378047e622
commit
bf7982c56b
4 changed files with 20 additions and 8 deletions
|
|
@ -2,7 +2,7 @@ from pathlib import Path
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.middleware.wsgi import WSGIMiddleware
|
from fastapi.middleware.wsgi import WSGIMiddleware
|
||||||
from fastapi.responses import RedirectResponse
|
from fastapi.responses import FileResponse, RedirectResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
|
||||||
from ...constants import DASHBOARD_PATH
|
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:
|
def bootstrap_dashboard(app: FastAPI, function_name: str, documentation: str) -> None:
|
||||||
dash_app = create_dash_app(function_name, app.version, documentation)
|
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.mount(DASHBOARD_PATH, WSGIMiddleware(dash_app))
|
||||||
|
|
||||||
@app.get("/", include_in_schema=False)
|
@app.get("/", include_in_schema=False)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,11 @@ from starlette.responses import HTMLResponse
|
||||||
def bootstrap_docs_endpoints(app: FastAPI) -> None:
|
def bootstrap_docs_endpoints(app: FastAPI) -> None:
|
||||||
@app.get("/docs", include_in_schema=False)
|
@app.get("/docs", include_in_schema=False)
|
||||||
def custom_swagger_ui_html() -> HTMLResponse:
|
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)
|
@app.get("/docs/index.html", include_in_schema=False)
|
||||||
def redirect_to_docs() -> RedirectResponse:
|
def redirect_to_docs() -> RedirectResponse:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
:root {
|
:root {
|
||||||
--background-color: #edf5f6;
|
--background-color: #edf5f6;
|
||||||
|
--dark-background-color: #e7eced;
|
||||||
|
--light-text-color: #9a9fa0;
|
||||||
--small-padding: 10px;
|
--small-padding: 10px;
|
||||||
--medium-padding: 20px;
|
--medium-padding: 20px;
|
||||||
--large-padding: 40px;
|
--large-padding: 40px;
|
||||||
|
|
@ -147,7 +149,7 @@ main > header > *:nth-child(2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
main > header .placeholder {
|
main > header .placeholder {
|
||||||
opacity: 0.35;
|
color: var(--light-text-color);
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
display: block;
|
display: block;
|
||||||
|
|
@ -205,7 +207,6 @@ main > header .placeholder {
|
||||||
}
|
}
|
||||||
|
|
||||||
main > footer {
|
main > footer {
|
||||||
opacity: 0.35;
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -214,7 +215,8 @@ main > footer {
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: var(--large-padding);
|
padding: var(--large-padding);
|
||||||
background-color: #ddd;
|
background-color: var(--dark-background-color);
|
||||||
|
color: var(--light-text-color);
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -225,10 +227,11 @@ main > footer {
|
||||||
a img {
|
a img {
|
||||||
display: block;
|
display: block;
|
||||||
margin-left: var(--large-padding);
|
margin-left: var(--large-padding);
|
||||||
width: 64px;
|
width: 80px;
|
||||||
height: 64px;
|
height: 80px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: transform 300ms;
|
transition: transform 300ms;
|
||||||
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
a img:hover {
|
a img:hover {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ def get_footer() -> html.Footer:
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
html.A(
|
html.A(
|
||||||
html.Img(src="/assets/github.png"),
|
html.Img(src="/assets/logo.png"),
|
||||||
href=GITHUB_LINK,
|
href=GITHUB_LINK,
|
||||||
target="_blank",
|
target="_blank",
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue