Bor
Bor

Reputation: 793

Flask's send_from_directory from Azure Container

I've seen the similar questions, but this is specific for Azure container.

There's a Storage Account(SA) and container(das_container)

The HTML page has a button where the user should be able to download the blob(ja_file.txt) from the das_container with click on the button

<input type="submit" value="dw_button" name="dw_button" />

Flask part:

@app.route("/<path:path>")
def get_file(path):
    return send_from_directory('/<directory-on-azure-container>',filename='ja_file.txt', as_attachment=True)


@app.route('/index', methods=['POST'])
def yes_download():
    if request.method == 'POST':
        x = request.form.to_dict()
        if 'dw_button' in x:
            get_file(path)

The BlockBlobService is setup.

The question is how to set the path to Azure container in the get_file() method? The premise of the question is that's the problem.

Upvotes: 1

Views: 214

Answers (1)

Jason Pan
Jason Pan

Reputation: 22019

send_from_directory is used to read the path where the project is deployed on the webserver.

It is recommended to download the file or create an HttpClient, and then process the file through Http request, which can return to the form of Stream. Of course, you can also find a package for use.

Upvotes: 1

Related Questions