如何在from_目录Flas中给出绝对路径

2024-04-20 12:46:00 发布

您现在位置:Python中文网/ 问答频道 /正文

默认情况下,send_from_directory函数似乎将提供给它的路径作为其项目目录的相对路径。我们如何才能提供一条通往它的绝对路径?在

    @app.route('/download/<file>',methods=['GET'])
    def download_function(file):
        return send_from_directory("~/Desktop", file, as_attachment=True)

Tags: 项目函数from路径目录sendappget