Serve uploads from UPLOAD_FOLDER so it can live on a mounted volume

This commit is contained in:
jessikitty committed 2026-09-24 19:48:29 +10:00
1 parent 04c5eddd17
commit 6821b67941
1 file changed
+11
+11
View File
@@ -73,6 +73,17 @@ def create_app(config_name='default'):
# Create backup directory
os.makedirs(app.config['BACKUP_FOLDER'], exist_ok=True)
# Serve uploads from UPLOAD_FOLDER wherever it lives.
# Stored paths are rendered as /static/uploads/<path>, which only works
# by accident when UPLOAD_FOLDER sits inside app/static. This explicit
# route takes precedence over Flask's static handler and keeps those
# URLs valid when the folder is a mounted volume (e.g. /data/uploads).
from flask import send_from_directory
@app.route('/static/uploads/<path:filename>')
def uploaded_file(filename):
return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
# Register CLI commands (flask backup create/list/verify/restore)
from app.cli import register_cli
register_cli(app)