def login_landing_uri()

in dialogflow-cx/vpc-sc-demo/backend/session_utilities.py [0:0]


def login_landing_uri(request, query_params=None):
    """Helper function to get landing location on host after login (dev and prod)."""
    if query_params is None:
        query_params = {}
    if request.host_url == "http://localhost:5001/":
        assert not is_prod()
        landing_uri = f"http://{DEBUG_DOMAIN}:3000"
    elif request.host_url == "http://localhost:8081/":
        assert not is_prod()
        landing_uri = f"http://{DEBUG_DOMAIN}:8080"
    else:
        assert is_prod()
        landing_uri = request.host_url.replace("http://", "https://")

    if landing_uri[-1] == "/":
        landing_uri = landing_uri[:-1]

    if query_params:
        param_string = "&".join([f"{key}={val}" for key, val in query_params.items()])
        landing_uri = f"{landing_uri}/?{param_string}"

    return landing_uri