diff --git a/app.py b/app.py index a04a5ef..f766e8e 100644 --- a/app.py +++ b/app.py @@ -81,6 +81,17 @@ def create(): content=request.form['content'] cat_title=request.form['cat'] + #create a new category: + new_category = request.form['new_category'] + # if a new category_title is created add it to the table of categories + if cat_title == 'New category' and new_category: + conn.execute('INSERT INTO categories (title) VALUES (?)', + (new_category,)) + conn.commit() + # update cat_title to refer to the newly added category + cat_title = new_category + + if not content: flash('plz write a content!') return redirect(url_for('home')) diff --git a/library.db b/library.db index 590a14d..1aab9d2 100644 Binary files a/library.db and b/library.db differ diff --git a/templates/create.html b/templates/create.html index 0b0c822..a7e0520 100644 --- a/templates/create.html +++ b/templates/create.html @@ -14,6 +14,7 @@
+
+ + +