def download_file(url: str, *, download_path: Optional[Path] = None) -> str:
    """Download to cwd with filename as last part of address, return filepath.

    Returns
    -------
    str
        Path to the downloaded file on disk
    download_path
        kwarg only which specifies the path to download the file to.
        By default, None.

    TODO
    ----
    *  cleanup on error
    *  allow specific file names

    """
    fname = f"{url.split('/')[-1]}"
    fpath = str(download_path.absolute()) if download_path is not None else f"./{fname}"

    response = requests.get(url, stream=True)
    nbytes = int(response.headers.get("content-length", 0))
    with tqdm.wrapattr(open(fpath, "wb"), "write", miniters=1, desc=fname, total=nbytes) as f:
        for chunk in response.iter_content(chunk_size=1024):
            if chunk:  # filter out keep-alive new chunks
                f.write(chunk)

    return fpath
Download to cwd with filename as last part of address, return filepath.

    Returns
    -------
    str
        Path to the downloaded file on disk
    download_path
        kwarg only which specifies the path to download the file to.
        By default, None.

    TODO
    ----
    *  cleanup on error
    *  allow specific file names

    
src/flash/core/serve/utils.py