Black Lives Matter. Please consider donating to Black Girls Code today.

Several assets folders

Hello!
My dash app is a report that can be used on different datasets which include audio files on local computer of a user. I cant move this audio files in the assets folder every time a person runs my app because they can take gigobytes and there are tons of different datasets. I know that I can specify assets folder when running my app, but my app also already has a normal assets folder with css and etc.

So I wonder how can I provide html.Audio(src=local_path) and not put those files in my existing assets folder. Mayby there is a way to specify several assets folders.

In this case, you can direct flask to make certain folders upload-able with custom routes. see https://flask.palletsprojects.com/en/1.1.x/api/#flask.send_from_directory

In flask’s documentation, app refers to dash’s app.server, so you would have

import flask


@app.server.route('/uploads/<path:filename>')
def download_file(filename):
    return flask.send_from_directory(some_other_directory,
                               filename, as_attachment=True)

I’m not sure what the syntax is for some_other_directory, but that should give you an idea.