MCPcopy Create free account
hub / github.com/microsoft/Webwright / task_view

Function task_view

assets/task_showcase/app.py:196–234  ·  view source on GitHub ↗
(short_id: str)

Source from the content-addressed store, hash-verified

194
195@app.route("/task/<short_id>")
196def task_view(short_id: str):
197 task_dir = TASKS_DIR / short_id
198 info_path = task_dir / "task.json"
199 if not info_path.exists():
200 abort(404)
201 info = json.loads(info_path.read_text())
202 info["short_id"] = short_id
203 steps, final = build_steps(task_dir)
204 # last-modified timestamp of the run for the "Updated" line
205 import datetime as _dt
206 log_path = task_dir / "final_script_log.txt"
207 if log_path.exists():
208 ts = _dt.datetime.fromtimestamp(log_path.stat().st_mtime)
209 updated = ts.strftime("%-m/%-d/%Y, %-I:%M:%S %p")
210 else:
211 updated = ""
212 # Per-task structured report lives next to the run artifacts.
213 report_path = task_dir / "report.json"
214 if report_path.exists():
215 report = json.loads(report_path.read_text())
216 else:
217 report = {}
218 sources = report.get("sources", [])
219 result = report.get("result", {"sections": []})
220 num_steps = len(steps)
221 if not num_steps:
222 try:
223 num_steps = int(info.get("num_steps") or 0)
224 except (TypeError, ValueError):
225 num_steps = 0
226 return render_template(
227 "task.html",
228 info=info,
229 final_response=final,
230 sources=sources,
231 result=result,
232 updated=updated,
233 num_steps=num_steps,
234 )
235
236
237@app.route("/task/<short_id>/screenshot/<path:filename>")

Callers

nothing calls this directly

Calls 1

build_stepsFunction · 0.85

Tested by

no test coverage detected