mirror of
https://github.com/fusion44/blitz_api.git
synced 2026-08-16 12:20:14 +02:00
As of sse-starlette 0.7.x the requirements changed to Python 2.8 which is not yet available for Raspiblitz. The source file doesn't require actually Python 2.8 => Integrate directly into Blitz API source
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
import app.repositories.apps as repo
|
|
import app.routers.apps_docs as docs
|
|
from app.auth.auth_bearer import JWTBearer
|
|
from app.sse_starlette import EventSourceResponse
|
|
from fastapi import APIRouter, HTTPException, status
|
|
from fastapi.params import Depends
|
|
|
|
router = APIRouter(
|
|
prefix="/apps",
|
|
tags=["Apps"]
|
|
)
|
|
|
|
|
|
@router.get("/status",
|
|
summary="Get the status of currently installed apps.",
|
|
response_description=docs.get_app_status_response_docs,
|
|
dependencies=[Depends(JWTBearer())],
|
|
status_code=status.HTTP_200_OK)
|
|
def get_status():
|
|
try:
|
|
return repo.get_app_status()
|
|
except:
|
|
return HTTPException(status.HTTP_500_INTERNAL_SERVER_ERROR, detail="Unknown error")
|
|
|
|
|
|
@router.get("/status_sub",
|
|
summary="Subscribe to status changes of currently installed apps.",
|
|
response_description=docs.get_app_status_sub_response_docs,
|
|
dependencies=[Depends(JWTBearer())],
|
|
status_code=status.HTTP_200_OK)
|
|
async def get_status():
|
|
try:
|
|
return EventSourceResponse(repo.get_app_status_sub())
|
|
except:
|
|
return HTTPException(status.HTTP_500_INTERNAL_SERVER_ERROR, detail="Unknown error")
|