Skip to content

Commit

Permalink
routers: add GET /api/version
Browse files Browse the repository at this point in the history
Expose WAS_VERSION on /api/version so we can show the version in the UI.

Closes: #50
  • Loading branch information
stintel committed Jan 10, 2024
1 parent 6d4c6ea commit a1540f4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from .routers import ota
from .routers import release
from .routers import status
from .routers import version


logging.basicConfig(
Expand Down Expand Up @@ -135,6 +136,7 @@ def api_redirect_admin():
app.include_router(ota.router)
app.include_router(release.router)
app.include_router(status.router)
app.include_router(version.router)


# WebSockets with params return 403 when done with APIRouter
Expand Down
21 changes: 21 additions & 0 deletions app/routers/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from logging import getLogger

from fastapi import APIRouter, Request
from fastapi.responses import JSONResponse

from app.settings import settings

log = getLogger("WAS")

router = APIRouter(
prefix="/api",
)


@router.get("/version")
async def api_get_version(request: Request):
log.debug('API GET VERSION: Request')

was_version = settings.was_version

return JSONResponse({'was_version': was_version})

0 comments on commit a1540f4

Please sign in to comment.