(task_id: str)
| 158 | |
| 159 | @bp.post("/api/tasks/<task_id>/answer") |
| 160 | def api_task_answer(task_id: str): |
| 161 | run_root = _resolve_run_root(get_visualizer_path()) |
| 162 | qdir = _queue_dir(run_root) |
| 163 | |
| 164 | # Accept form POST (current UI), optionally JSON too. |
| 165 | answer = (request.form.get("answer") or "").strip() |
| 166 | if not answer and request.is_json: |
| 167 | body = request.get_json(silent=True) or {} |
| 168 | answer = str(body.get("answer") or "").strip() |
| 169 | |
| 170 | if not answer: |
| 171 | return ("Answer must not be empty", 400) |
| 172 | |
| 173 | if not (qdir / f"{task_id}.json").exists(): |
| 174 | return ("Task not found", 404) |
| 175 | |
| 176 | _write_answer(qdir, task_id, answer) |
| 177 | return jsonify({"ok": True}) |
| 178 | |
| 179 | return bp |
nothing calls this directly
no test coverage detected