from typing import Optional
import requests


def _send_request(request_url: str) -> Optional[dict]:
    """Sends request to the specified URL and returns a dictionary
    containing the response

    :param request_url: url to which the request will be sent
    :type request_url: str

    :return: response in a form of a dictionary or None if the response status
        code is 404 or 401
    :rtype: Optional[dict]

    :raises: ValueError when incorrect response status code
    """
    response = requests.get(request_url)

    if response:
        return response.json()
    else:
        if response.status_code == 404:
            print("\nWeather information not found.\n")
        elif response.status_code == 401:
            print("\nValidation error, please contact the developer.")
        else:
            raise ValueError(f"Invalid response code: {response.status_code}!")
        return None