Initial project import: Flask app, templates, init script, README

This commit is contained in:
Albert
2025-11-08 23:25:18 +01:00
commit 4b4a3fb56f
7 changed files with 240 additions and 0 deletions

24
init_db.py Normal file
View File

@@ -0,0 +1,24 @@
from app import app, db, Frage
def init_db():
# Ensure we run DB commands inside the Flask application context
with app.app_context():
db.drop_all()
db.create_all()
sample = [
'Haben Sie besondere Ernährungsbedürfnisse?',
'Benötigen Sie eine Übernachtung?',
'Möchten Sie unseren Newsletter erhalten?'
]
for text in sample:
f = Frage(text=text)
db.session.add(f)
db.session.commit()
print('DB initialisiert und Beispiel-Fragen angelegt.')
if __name__ == '__main__':
init_db()