Python Flask send_static_file没有显示chrome中的进度条

时间:2015-01-06 12:56:30

标签: python flask

@app.route("/send_static_file")
def send_static_file:
    file_name = "a.db.gz"
    return app.send_static_file(file_name)

send_static_file未显示chrome中的进度条。我没有在Chrome的Inspect工具中看到Content-Length响应标题,但是在curl中它显示了响应标题。

1 个答案:

答案 0 :(得分:1)

试试这个:

from flask import make_response
import os

@app.route("/send_static_file")
def send_static_file:
    file_name = "a.db.gz"
    response = make_response(app.send_static_file(file_name))
    response.headers['content-length'] = str(os.path.getsize(file_name)))
    return response