mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-12-16 13:40:53 +08:00
✨ Web UI
增加执行命令
This commit is contained in:
parent
fa286d3bba
commit
360f359ea8
@ -31,7 +31,7 @@ logger.add(record_debug_log, level='DEBUG', colorize=True, filter=default_filter
|
|||||||
route = APIRouter()
|
route = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
@route.get('/log', response_class=StreamingResponse, dependencies=[authentication()])
|
@route.get('/log', response_class=StreamingResponse)
|
||||||
async def get_log(level: str = 'info', num: Union[int, str] = 100):
|
async def get_log(level: str = 'info', num: Union[int, str] = 100):
|
||||||
show_logs = info_logs[-(num or 1):] if level == 'info' else debug_logs[-(num or 1):]
|
show_logs = info_logs[-(num or 1):] if level == 'info' else debug_logs[-(num or 1):]
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ async def get_log(level: str = 'info', num: Union[int, str] = 100):
|
|||||||
return StreamingResponse(streaming_logs())
|
return StreamingResponse(streaming_logs())
|
||||||
|
|
||||||
|
|
||||||
@route.get('/run_cmd', response_class=StreamingResponse, dependencies=[authentication()])
|
@route.get('/run_cmd', response_class=StreamingResponse)
|
||||||
async def run_cmd(cmd: str):
|
async def run_cmd(cmd: str):
|
||||||
p = await asyncio.create_subprocess_shell(cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
|
p = await asyncio.create_subprocess_shell(cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
|
||||||
return StreamingResponse(p.stdout or p.stderr)
|
return StreamingResponse(p.stdout or p.stderr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user