Flask/Werkzeug how to attach HTTP content-length header to file download

后端 未结 3 1456
星月不相逢
星月不相逢 2020-12-14 18:49

I am using Flask (based on Werkzeug) which uses Python.

The user can download a file, I\'m using the send_from_directory-function.

However when actually down

3条回答
  •  心在旅途
    2020-12-14 19:41

    Since version 0.6 the canonical way to add headers to a response object is via the make_response method (see Flask docs).

    def index():
        response = make_response(render_template('index.html', foo=42))
        response.headers['X-Parachutes'] = 'parachutes are cool'
        return response
    

提交回复
热议问题