import requests
import json


def get_driving_distance(start_point, end_point):
    """Gets the driving distance (km) from the start point to the end point (input in [lat, long])."""

    # call the OSMR API - needs [long, lat]
    r = requests.get(
        f"http://router.project-osrm.org/route/v1/car/{end_point[1]},{end_point[0]};{start_point[1]},{start_point[0]}?overview=false""")
    # then you load the response using the json libray
    # by default you get only one alternative so you access 0-th element of the `routes`
    routes = json.loads(r.content)
    route_1 = routes.get("routes")[0]
    driving_distance = route_1["distance"] / 1000

    return driving_distance