From f28b8a66d7a901cc554a18f7ef6608c962531ab7 Mon Sep 17 00:00:00 2001 From: Iam54r1n4 Date: Sun, 2 Feb 2025 18:41:39 +0000 Subject: [PATCH] Fix one endpoint --- core/scripts/webpanel/app.py | 13 ++++++------- .../webpanel/routers/api/v1/config/singbox.py | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/scripts/webpanel/app.py b/core/scripts/webpanel/app.py index 6d61fbf..0daf512 100644 --- a/core/scripts/webpanel/app.py +++ b/core/scripts/webpanel/app.py @@ -11,28 +11,27 @@ from starlette.staticfiles import StaticFiles HYSTERIA_CORE_DIR = '/etc/hysteria/core/' # Append directory of cli_api.py to be able to import it sys.path.append(HYSTERIA_CORE_DIR) # Now we can do `import cli_api` -# This import should be after the sys.path modification, because it imports cli_api -import routers # noqa +import routers # noqa: This import should be after the sys.path modification, because it imports cli_api +import cli_api # noqa # region Setup App app = FastAPI(debug=True) app.mount('/assets', StaticFiles(directory='assets'), name='assets') templates = Jinja2Templates(directory='templates') -# TODO: fix this -# app.add_middleware(SessionMiddleware, secret_key='your-secret-key') +# app.add_middleware(SessionMiddleware, secret_key='your-secret-key') # TODO: fix this # endregion # region Routers -# Add API version 1 router -app.include_router(routers.api.v1.api_v1_router, prefix='/api/v1', tags=['v1']) +app.include_router(routers.api.v1.api_v1_router, prefix='/api/v1', tags=['v1']) # Add API version 1 router # Add basic routes @app.get('/') async def index(request: Request): - return templates.TemplateResponse('index.html', {'request': request}) + users = cli_api.list_users() + return templates.TemplateResponse('index.html', {'request': request, 'users': users}) @app.get('/home') diff --git a/core/scripts/webpanel/routers/api/v1/config/singbox.py b/core/scripts/webpanel/routers/api/v1/config/singbox.py index eec2459..e4bf66c 100644 --- a/core/scripts/webpanel/routers/api/v1/config/singbox.py +++ b/core/scripts/webpanel/routers/api/v1/config/singbox.py @@ -26,8 +26,8 @@ async def start(body: StartInputBody): raise HTTPException(status_code=400, detail=f'Error: {str(e)}') -@router.get('/stop', response_model=DetailResponse, summary='Stop Singbox') -async def delete(): +@router.delete('/stop', response_model=DetailResponse, summary='Stop Singbox') +async def stop(): """ Stop the Singbox service.