gunicorn和nginx背后的Flask应用程序只是流式文件,不允许下载

gunicorn和nginx背后的Flask应用程序只是流式文件,不允许下载,nginx,flask,gunicorn,Nginx,Flask,Gunicorn,我目前在一个子域上有一个应用程序,名为api.example.com,我有example.com将一个带有api.example.com的文件放入HTML流中,而不是将其发送供下载 HTML看起来是这样的 <a href="https://api.example.com/path/to/file" download="https://api.example.compath/to/file"> 这是我的枪角 [program:api] comm

我目前在一个子域上有一个应用程序,名为
api.example.com
,我有
example.com
将一个带有
api.example.com
的文件放入HTML流中,而不是将其发送供下载

HTML看起来是这样的

<a href="https://api.example.com/path/to/file" download="https://api.example.compath/to/file">
这是我的枪角

[program:api]
command = /home/www/env/bin/gunicorn run:app -b localhost:8000
environment=PATH="/home/www/env/bin:%(ENV_PATH)s"
directory = /home/www/api
user = api
stdout_logfile = /var/log/api/api.out.log
stderr_logfile = /var/log/api/api.err.log
flask应用程序在本地服务器上运行。但当我把它放到现场时,它不是发送mp3文件下载,而是在浏览器中打开它


任何帮助都将不胜感激。

我不得不把这个放到nginx路线上

    location /static/downloads/  {
                autoindex on;
                alias /home/www/api/static/downloads/;
                expires 30d;
                        if ( $request_filename ~ "^.*/(.+.*)$" ){
                        set $fname $1;
                        add_header Content-Disposition 'attachment; filename="$fname"';
        }
    }
[program:api]
command = /home/www/env/bin/gunicorn run:app -b localhost:8000
environment=PATH="/home/www/env/bin:%(ENV_PATH)s"
directory = /home/www/api
user = api
stdout_logfile = /var/log/api/api.out.log
stderr_logfile = /var/log/api/api.err.log
    location /static/downloads/  {
                autoindex on;
                alias /home/www/api/static/downloads/;
                expires 30d;
                        if ( $request_filename ~ "^.*/(.+.*)$" ){
                        set $fname $1;
                        add_header Content-Disposition 'attachment; filename="$fname"';
        }
    }