From a6a84d662badd8a4c3950204ee4a0735bc498cd8 Mon Sep 17 00:00:00 2001 From: Arian Nasr Date: Sat, 4 Apr 2026 16:13:00 -0400 Subject: [PATCH] deploy with gunicorn --- gunicorn.conf.py | 16 ++++++++++++++++ main.py | 6 ------ requirements.txt | 3 ++- 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 gunicorn.conf.py diff --git a/gunicorn.conf.py b/gunicorn.conf.py new file mode 100644 index 0000000..967078a --- /dev/null +++ b/gunicorn.conf.py @@ -0,0 +1,16 @@ +# gunicorn.conf.py +# Arian Nasr +# April 4, 2026 + +import os + + +BIND_ADDRESS = os.environ.get('BIND_ADDRESS', '0.0.0.0') +BIND_PORT = int(os.environ.get('BIND_PORT', 5001)) + +bind = f"{BIND_ADDRESS}:{BIND_PORT}" +workers = 2 +accesslog = "-" # Log to stdout +errorlog = "-" # Log to stderr + +# gunicorn -c gunicorn.conf.py main:app \ No newline at end of file diff --git a/main.py b/main.py index 859ef7d..921d8cf 100644 --- a/main.py +++ b/main.py @@ -7,8 +7,6 @@ from flask import Flask, request, render_template from werkzeug.utils import secure_filename UPLOAD_FOLDER = os.environ.get('NAVIDROME_MUSIC_FOLDER', '/opt/navidrome/music') -BIND_ADDRESS = os.environ.get('BIND_ADDRESS', '0.0.0.0') -BIND_PORT = int(os.environ.get('BIND_PORT', 5001)) ALLOWED_EXTENSIONS = {'flac', 'mp3', 'wav'} app = Flask(__name__) @@ -35,7 +33,3 @@ def upload_file(): return render_template('success.html', success_message=f'{len(request.files)} file(s) uploaded successfully!'), 200 return render_template('index.html'), 200 - - -if __name__ == '__main__': - app.run(host=BIND_ADDRESS, port=BIND_PORT, debug=False) diff --git a/requirements.txt b/requirements.txt index 2ac7c70..3a9aa9c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,5 @@ Flask==3.1.3 itsdangerous==2.2.0 Jinja2==3.1.6 MarkupSafe==3.0.3 -Werkzeug==3.1.8 \ No newline at end of file +Werkzeug==3.1.8 +gunicorn==25.3.0 \ No newline at end of file