async def log_view(name: str, worktime_for_url: str, request: Request): import re item: FlowItem = FlowItem.get_or_none( **{ FlowItem.name.name: name, FlowItem.worktime.name: FlowItem.worktime_from_url( worktime_for_url), }) if item.logpath: if pathlib.Path.exists(pathlib.Path(item.logpath)): with open(item.logpath, "r", encoding="UTF8") as f: logtext = f.read() logtext = re.sub(r"\[\d\dm|\[\dm", "", logtext) else: logtext = "Logs not found: 'Logs file missing'" else: logtext = "Logs not found: 'Logs path missing'" return templates.TemplateResponse( "/pages/log.html", context={ "request": request, "content": logtext, "filepath": item.logpath, }, )
async def restart_task_view(name: str, worktime_for_url: str): worktime = FlowItem.worktime_from_url(worktime_for_url) FlowItem.recreate_item(name, worktime) return RedirectResponse(f"/notebook/{name}/tasks")