mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-13 11:39:45 +08:00
change: status api.
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
### Features
|
||||
|
||||
- 增加 `i18n` 支持,目前支持 `zh-CN` 和 `en-US`。
|
||||
- 增加 pwa 支持。
|
||||
- 增加 RSS 管理页面。
|
||||
- 增加搜索顶栏。
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ app = create_app()
|
||||
|
||||
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")
|
||||
|
||||
@@ -73,16 +73,19 @@ if VERSION != "DEV_VERSION":
|
||||
# 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")
|
||||
context = {"request": request}
|
||||
return templates.TemplateResponse("index.html", context)
|
||||
|
||||
# # HTML Response
|
||||
# @app.get("/{full_path:path}", response_class=HTMLResponse, tags=["html"])
|
||||
# def index(request: Request):
|
||||
# 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)
|
||||
|
||||
|
||||
@@ -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")
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user