from flask import request, Blueprint, Response

currency = Blueprint('currency', __name__)


@currency.route('/exchange_rate', methods=['GET'])
def translate():
    from_currency = request.args.get("from")
    to_currency = request.args.get("to")

    if not from_currency or not to_currency:
        raise ValueError("Invalid params")

    if from_currency != "rmb" or to_currency != "dollar":
        raise ValueError("From must is rmb and to must is dollar")

    exchange_rate = "6.5"

    return Response(exchange_rate, mimetype='application/json')