Skip to content

bovine_herd.server.utils

path_from_request(request)

Given a request (from quart) determines the url it is coming from. Main goal is to abstract away http vs https

Source code in bovine_herd/bovine_herd/server/utils.py
def path_from_request(request) -> str:
    """Given a request (from quart) determines the url it is coming from.
    Main goal is to abstract away http vs https"""

    url = request.url
    if request.headers.get("X-Forwarded-Proto") == "https":
        url = url.replace("http://", "https://")

    return urljoin(url, urlparse(url).path)