def index()

in project/paperbench/paperbench/gui/app.py [0:0]


def index():
    with lock:  # Use lock to support concurrent requests
        try:
            with open(app.config["PATH_TO_PAPER"] / app.config["RUBRIC_FILE_NAME"], "r") as f:
                data = json.load(f)

            task_node = app.config["NODE_TYPE"].from_dict(data)
            if app.config.get("GRADED", False):
                task_node = update_all_grades(task_node)
                with open(app.config["PATH_TO_PAPER"] / app.config["RUBRIC_FILE_NAME"], "w") as f:
                    json.dump(task_node.to_dict(), f, indent=4)

            template = "rubric.html"

            return render_template(
                template,
                task_node=task_node,
                valid_task_categories=VALID_TASK_CATEGORIES,
                use_api=app.config["USE_API"],
            )
        except Exception as e:
            return jsonify(
                {
                    "status": "error",
                    "message": f"Error fetching the task tree: {e}",
                }
            )