from __future__ import annotations from pydantic import ValidationError from quart import Blueprint, jsonify from app.ab_test import GetCoverService from app.api.v1.utils import ApiDependencies from app.api.v1.utils import GetCoverRequest from app.api.v1.utils import parse_json, validation_error_response def create_abtest_bp(deps: ApiDependencies) -> Blueprint: bp = Blueprint("abtest", __name__) @bp.route("/get_cover", methods=["POST"]) async def get_cover(): try: _, body = await parse_json(GetCoverRequest) except ValidationError as e: payload, status = validation_error_response(e) return jsonify(payload), status service = GetCoverService(deps.db, body) result = await service.deal() return jsonify(result) return bp