Add download links to files in the same folder as app.py

Hi I have an app and I want to offer demo files for people to upload. But first they need to download them. They are stored in a folder under the root of app.py
I just want them to be available for download.
I donโ€™t want to use a download button. Ideally I want an old-fashioned link that will download the file
Also, I would like this link to be in a st.info() but that is optional
Thanks

I use this function that I found in the forum:

def get_binary_file_downloader_html(bin_file, file_label='File'):
    with open(bin_file, 'rb') as f:
        data = f.read()
    bin_str = base64.b64encode(data).decode()
    href = f'<a href="data:application/octet-stream;base64,{bin_str}" download="{os.path.basename(bin_file)}">Download a demo {file_label}</a>'
    return href
1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.