-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.py
33 lines (22 loc) · 1 KB
/
root.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from flask import Blueprint, render_template, redirect, url_for, request
from datas import *
root_pages = Blueprint('root_pages', __name__, template_folder='templates')
createDatabase()
@root_pages.route('/viewWords')
def viewWords():
words = selectAllJoin()
return render_template('view-words.html', words=words)
@root_pages.route('/addWords')
def addWords():
category_words = select('SELECT * FROM tbl_category_words')
return render_template('add-items.html', categoryWords=category_words)
@root_pages.route('/viewNewItems', methods=["GET", "POST"])
def viewNewItems():
if request.method == "POST":
newCategory = request.form['newCategory']
newWord = request.form['newWords']
categories = validateAndAddNewCategories(newCategory)
words = validateAndAddNewWords(newWord)
return render_template('view-new-items.html', addWords=words["add"], notAddWords=words["notAdd"], addCategories=categories["add"], notAddCategories=categories["notAdd"])
else:
return redirect(url_for('root_pages.addWords'))