Flask send_file is sending old file instead of newest

前端 未结 1 672
再見小時候
再見小時候 2021-02-20 08:18

I have a flask app where using one Flask route the server creates a csv file and saves it to the server. Using a generated button on the client page, another Flask

相关标签:
1条回答
  • 2021-02-20 08:45

    send_file has a caching timeout that you are not configuring. It will send the same file that has been cached unless you tell it not to cache the file like so:

    send_file('./tmp/{}'.format(basename), as_attachment=True, cache_timeout=0)
    

    See the following references for more information:

    http://flask.pocoo.org/docs/1.0/api/#flask.send_file

    http://flask.pocoo.org/docs/1.0/api/#flask.Flask.get_send_file_max_age

    http://flask.pocoo.org/docs/1.0/config/#SEND_FILE_MAX_AGE_DEFAULT

    0 讨论(0)
提交回复
热议问题