Skip to content

Commit

Permalink
main: add route for favicon.ico
Browse files Browse the repository at this point in the history
This avoids a 404 when the browser tries to get favicon.ico.

TODO: convert icon and add in static/favicon.ico
  • Loading branch information
stintel committed Dec 7, 2023
1 parent 0c785bc commit 3a9be8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
DB_URL = 'sqlite:////app/storage/was.db'
DIR_ASSET = '/app/storage/asset'
DIR_OTA = '/app/storage/ota'
FAVICON_PATH = '/app/static/favicon.ico'
URL_WILLOW_RELEASES = 'https://worker.heywillow.io/api/release?format=was'
URL_WILLOW_CONFIG = 'https://worker.heywillow.io/api/config'
URL_WILLOW_TZ = 'https://worker.heywillow.io/api/asset?type=tz'
Expand Down
8 changes: 7 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
WebSocketDisconnect,
)
from contextlib import asynccontextmanager
from fastapi.responses import RedirectResponse
from fastapi.responses import FileResponse, RedirectResponse
from fastapi.staticfiles import StaticFiles
import logging
from pathlib import Path
Expand All @@ -23,6 +23,7 @@
from app.const import (
ALEMBIC_CONFIG,
DIR_OTA,
FAVICON_PATH,
STORAGE_USER_CONFIG,
)

Expand Down Expand Up @@ -159,6 +160,11 @@ def api_redirect_admin():
return "/admin"


@app.get('/favicon.ico', include_in_schema=False)
async def favicon():
return FileResponse(FAVICON_PATH)


app.include_router(asset.router)
app.include_router(client.router)
app.include_router(config.router)
Expand Down

0 comments on commit 3a9be8e

Please sign in to comment.