Skip to content

Commit

Permalink
change: status api.
Browse files Browse the repository at this point in the history
  • Loading branch information
EstrellaXD committed Aug 13, 2023
1 parent 3f99245 commit 95ff5d5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
### Features

- 增加 `i18n` 支持,目前支持 `zh-CN``en-US`
- 增加 pwa 支持。
- 增加 RSS 管理页面。
- 增加搜索顶栏。

Expand Down
17 changes: 10 additions & 7 deletions backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_app() -> FastAPI:

if VERSION != "DEV_VERSION":
app.mount("/assets", StaticFiles(directory="dist/assets"), name="assets")
# app.mount("/pwa", StaticFiles(directory="dist/pwa"), name="pwa")
app.mount("/images", StaticFiles(directory="dist/images"), name="images")
# app.mount("/icons", StaticFiles(directory="dist/icons"), name="icons")
templates = Jinja2Templates(directory="dist")

Expand Down Expand Up @@ -73,16 +73,19 @@ def create_app() -> FastAPI:
# return FileResponse("dist/sw.js")

@app.get("/{path:path}")
def html(path: str):
def html(request: Request, path: str):
files = os.listdir("dist")
if path in files:
return FileResponse(f"dist/{path}")
else:
return FileResponse("dist/index.html")

# # HTML Response
# @app.get("/{full_path:path}", response_class=HTMLResponse, tags=["html"])
# def index(request: Request):
context = {"request": request}
return templates.TemplateResponse("index.html", context)

# HTML Response
# @app.get("/{path:path}", response_class=HTMLResponse, tags=["html"])
# def index(request: Request, path: str):
# print(request)
# print(path)
# context = {"request": request}
# return templates.TemplateResponse("index.html", context)

Expand Down
17 changes: 8 additions & 9 deletions backend/src/module/api/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,15 @@ async def program_status(current_user=Depends(get_current_user)):
if not current_user:
raise UNAUTHORIZED
if not program.is_running:
return {"status": "stop"}
return {
"status": False,
"version": VERSION,
}
else:
return {"status": "running"}
return {
"status": True,
"version": VERSION,
}


@router.get("/shutdown")
Expand All @@ -81,10 +87,3 @@ async def check_downloader_status(current_user=Depends(get_current_user)):
if not current_user:
raise UNAUTHORIZED
return program.check_downloader()


@router.get("/check/version", tags=["check"])
async def check_version(current_user=Depends(get_current_user)):
if not current_user:
raise UNAUTHORIZED
return VERSION

0 comments on commit 95ff5d5

Please sign in to comment.