Skip to content

Commit

Permalink
add 查询Release Api
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Aug 16, 2023
1 parent 66e1829 commit 73d3e2e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion app/api/endpoints/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@router.get("/env", summary="查询系统环境变量", response_model=schemas.Response)
def get_setting(_: schemas.TokenPayload = Depends(verify_token)):
"""
查询系统环境变量
查询系统环境变量,包括当前版本号
"""
info = settings.dict(
exclude={"SECRET_KEY", "SUPERUSER_PASSWORD", "API_TOKEN"}
Expand Down Expand Up @@ -153,3 +153,16 @@ def nettest(url: str,
})
else:
return schemas.Response(success=False, message="网络连接失败!")


@router.get("/versions", summary="查询Github所有Release版本", response_model=schemas.Response)
def latest_version(_: schemas.TokenPayload = Depends(verify_token)):
"""
查询Github所有Release版本
"""
version_res = RequestUtils().get_res(f"https://api.github.com/repos/jxxghp/MoviePilot/releases")
if version_res:
ver_json = version_res.json()
if ver_json:
return schemas.Response(success=True, data=ver_json)
return schemas.Response(success=False)
4 changes: 2 additions & 2 deletions app/schemas/response.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import Optional, Union

from pydantic import BaseModel

Expand All @@ -9,4 +9,4 @@ class Response(BaseModel):
# 消息文本
message: Optional[str] = None
# 数据
data: Optional[dict] = {}
data: Optional[Union[dict, list]] = {}

0 comments on commit 73d3e2e

Please sign in to comment.