from typing import Optional
import requests


def _find_city(ip: str) -> Optional[str]:
    """
    Uses ip-api to find the city in which an IP address is located.

    :param ip: the ip address to geolocate
    :return:   the city where theIP address is located or None
    """
    geo_ip_url = "http://ip-api.com/json/"

    # Query ip-api's geolocation API to locate the request's IP
    try:
        r = requests.get(f"{geo_ip_url}/{ip}")
        r.raise_for_status()
    except requests.exceptions.HTTPError:
        return

    geo_resp = r.json()
    if geo_resp.get("status") != "success":
        return

    return geo_resp.get("city")