diff --git a/Dockerfile b/Dockerfile index 65ac9cf..596a59a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,4 @@ COPY app.py app.py COPY requirements.txt requirements.txt RUN pip3 install -r requirements.txt RUN pip3 install -U flask-cors -CMD ["gunicorn", "-b", ":5000", "--timeout", "300", "app:app"] +CMD ["uwsgi", "--http-socket", "0.0.0.0:5000", "--socket-timeout", "600", "--processes", "4", "--threads", "2", "--wsgi-file", "app.py", "--callable", "app"] diff --git a/app.py b/app.py index f4f6044..f645708 100644 --- a/app.py +++ b/app.py @@ -8,6 +8,7 @@ import mysql.connector import logging import requests +from werkzeug.wsgi import FileWrapper import json app = Flask(__name__) @@ -128,7 +129,15 @@ def downloadFile(packageId, objectName): }] } requests.post(url, json=payload, headers={"Content-Type": "application/json"}) - return send_file(object, as_attachment=True, download_name=objectName) + file_wrapper = FileWrapper(object) + headers = { + 'Content-Disposition': 'attachment; filename="{}"'.format(objectName) + } + response = Response(file_wrapper, + mimetype='application/octet-stream', + direct_passthrough=True, + headers=headers) + return response except S3Error as err: logger.error(err) return err diff --git a/requirements.txt b/requirements.txt index 1ed6d31..0aad9f5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,4 @@ boto3 flask-cors mysql-connector-python requests -gunicorn \ No newline at end of file +uwsgi \ No newline at end of file