Skip to content

Commit

Permalink
[ENH] Summer mode controller
Browse files Browse the repository at this point in the history
  • Loading branch information
dragarthPl committed May 7, 2024
1 parent e2b734a commit 3c92de0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/summer_mode/summer_mode_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from fastapi import Request

from fastapi_injector import Injected
from fastapi_utils.cbv import cbv
from fastapi_utils.inferring_router import InferringRouter

from main.summer_mode.summer_mode import SummerMode

from main.summer_mode.summer_mode_repository import ISummerModeRepository

summer_mode_router = InferringRouter(tags=["SummerModeController"])


@cbv(summer_mode_router)
class SummerModeController:
summer_mode_repository: ISummerModeRepository = Injected(ISummerModeRepository)

@summer_mode_router.get("/api/summer_mode")
async def summer_mode(self, request: Request) -> str:
summer_mode: SummerMode = await self.summer_mode_repository.get_summer_mode()
if summer_mode:
return summer_mode.get_mode()
else:
return SummerMode.UNKNOWN

0 comments on commit 3c92de0

Please sign in to comment.