Version 1.1

This commit is contained in:
2026-01-28 15:31:49 +01:00
parent b5b11b5826
commit 105bcc8d7a
10 changed files with 553 additions and 4 deletions

20
app.py
View File

@@ -12,8 +12,18 @@ UPLOAD_FOLDER = 'static/uploads'
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
app = Flask(__name__)
app.config['SECRET_KEY'] = 'your_secret_key_here'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///liturgie.db'
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'your_secret_key_here')
# Prefer an env override, otherwise store the SQLite DB in Flask's `instance/` folder.
# This keeps the DB out of the repo root and makes Docker persistence easier.
default_db_path = os.path.join(app.instance_path, 'liturgie.db')
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
'SQLALCHEMY_DATABASE_URI',
f"sqlite:///{default_db_path}",
)
# Ensure the instance folder exists so SQLite can create/open the DB file.
os.makedirs(app.instance_path, exist_ok=True)
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
@@ -672,7 +682,11 @@ def change_password():
return render_template('change_password.html', msg=msg)
if __name__ == '__main__':
if not os.path.exists('liturgie.db'):
# Ensure instance folder exists when running without Docker.
os.makedirs(app.instance_path, exist_ok=True)
# Create DB on first run when using the default instance DB path.
if app.config['SQLALCHEMY_DATABASE_URI'].startswith('sqlite:///') and not os.path.exists(default_db_path):
with app.app_context():
db.create_all()
# Create initial admin user if not exists