def routes_safe_join(directory: DeveloperPath, path: UserProvidedPath) -> str:
    """Safely join the user path to the directory while performing some additional http-related checks,
    e.g. ensuring that the full path exists on the local file system and is not a directory
    """
    if path == "":
        raise fastapi.HTTPException(400)
    if route_utils.starts_with_protocol(path):
        raise fastapi.HTTPException(403)
    try:
        fullpath = Path(utils.safe_join(directory, path))
    except InvalidPathError as e:
        raise fastapi.HTTPException(403) from e
    if fullpath.is_dir():
        raise fastapi.HTTPException(403)
    if not fullpath.exists():
        raise fastapi.HTTPException(404)
    return str(fullpath)
Safely join the user path to the directory while performing some additional http-related checks,
    e.g. ensuring that the full path exists on the local file system and is not a directory
    
gradio/routes.py