def get_string(request, key):
    """Returns the first value in the request args for a given key."""
    if not request.args:
        return None

    if type(key) is not bytes:
        key = key.encode()

    if key not in request.args:
        return None

    val = request.args[key][0]
    if val is not None and type(val) is bytes:
        val = val.decode()

    return val