示例#1
0
def download(filename):
    path = get_archive_path(filename)
    if exists(path):
        return sendfile(filename)
    else:
        ## Hijack HEAD requests to check status, if the file is ready
        if request.method == 'HEAD':
            abort(404)
        make_archive(filename)
        return render_template("processing.html", url=url_for(
                'imaging.download', filename=filename))
示例#2
0
def sendfile(filename):
    if current_app.config["DEBUG"]:
        # Use flask during development
        return flask_send_file(get_archive_path(filename),
                               as_attachment=True)
    else:
        # Use nginx for the heavy lifting on the prod setup
        r = make_response()
        r.headers['Content-Type']=""
        r.headers['Content-Disposition'] = "attachment"
        r.headers['X-Accel-Redirect'] = "/dicom/" + filename
        return r