Fix one endpoint
This commit is contained in:
@ -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
|
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`
|
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: This import should be after the sys.path modification, because it imports cli_api
|
||||||
import routers # noqa
|
import cli_api # noqa
|
||||||
|
|
||||||
# region Setup App
|
# region Setup App
|
||||||
app = FastAPI(debug=True)
|
app = FastAPI(debug=True)
|
||||||
app.mount('/assets', StaticFiles(directory='assets'), name='assets')
|
app.mount('/assets', StaticFiles(directory='assets'), name='assets')
|
||||||
templates = Jinja2Templates(directory='templates')
|
templates = Jinja2Templates(directory='templates')
|
||||||
# TODO: fix this
|
# app.add_middleware(SessionMiddleware, secret_key='your-secret-key') # TODO: fix this
|
||||||
# app.add_middleware(SessionMiddleware, secret_key='your-secret-key')
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
# region Routers
|
# region Routers
|
||||||
# Add API version 1 router
|
app.include_router(routers.api.v1.api_v1_router, prefix='/api/v1', tags=['v1']) # Add API version 1 router
|
||||||
app.include_router(routers.api.v1.api_v1_router, prefix='/api/v1', tags=['v1'])
|
|
||||||
|
|
||||||
|
|
||||||
# Add basic routes
|
# Add basic routes
|
||||||
@app.get('/')
|
@app.get('/')
|
||||||
async def index(request: Request):
|
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')
|
@app.get('/home')
|
||||||
|
|||||||
@ -26,8 +26,8 @@ async def start(body: StartInputBody):
|
|||||||
raise HTTPException(status_code=400, detail=f'Error: {str(e)}')
|
raise HTTPException(status_code=400, detail=f'Error: {str(e)}')
|
||||||
|
|
||||||
|
|
||||||
@router.get('/stop', response_model=DetailResponse, summary='Stop Singbox')
|
@router.delete('/stop', response_model=DetailResponse, summary='Stop Singbox')
|
||||||
async def delete():
|
async def stop():
|
||||||
"""
|
"""
|
||||||
Stop the Singbox service.
|
Stop the Singbox service.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user