summaryrefslogtreecommitdiff
path: root/routes/base.py
diff options
context:
space:
mode:
authorSenni Heidari <sheidar2@local>2023-11-21 11:36:12 +0200
committerSenni Heidari <sheidar2@local>2023-11-21 11:36:12 +0200
commitb868d0ba58384fce5a9a45ae153dee9815327d55 (patch)
tree2d73e810cad9eba76121f28b07eeb49bf3f9e573 /routes/base.py
parent2ebfcf29c84b84999b76ff13150ba5a13fd3cac1 (diff)
Update directory hierarchy
Diffstat (limited to 'routes/base.py')
-rw-r--r--routes/base.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/routes/base.py b/routes/base.py
new file mode 100644
index 0000000..144eeef
--- /dev/null
+++ b/routes/base.py
@@ -0,0 +1,78 @@
+from app import app
+from flask import render_template,session
+import db_actions as D
+
+def get_alert():
+ if "alert" in session:
+ alert = session["alert"]
+ del session["alert"]
+ return f"{alert}"
+ return ""
+
+def get_nick():
+ while "id" in session.keys():
+ nick = D.user_get_nick(session["id"])
+ if not nick:
+ del session['id']
+ if "quiz_id" in session.keys():
+ del session['quiz_id']
+ break
+ return nick
+ return "(ei nimimerkkiä)"
+
+@app.route("/")
+def index():
+ return app.send_static_file("index.html")
+
+@app.route("/pages/info.html")
+def info():
+ return render_template("info.html",
+ alert=get_alert()
+ )
+
+@app.route("/pages/create.html")
+def create():
+ if "id" not in session.keys():
+ return "redirect = #nick"
+ if "quiz_id" not in session.keys():
+ return "redirect = #quiz"
+ return render_template("create.html",
+ alert=get_alert(),
+ nick=get_nick()
+ )
+
+@app.route("/pages/answer.html")
+def answer():
+ if "id" not in session.keys():
+ return "redirect = #nick"
+ return render_template("answer.html",
+ alert=get_alert(),
+ nick=get_nick()
+ )
+
+@app.route("/pages/analyse.html")
+def analyse():
+ if "id" not in session.keys():
+ return "redirect = #nick"
+ return render_template("analyse.html",
+ alert=get_alert(),
+ nick=get_nick()
+ )
+
+@app.route("/pages/moderate.html")
+def moderate():
+ return render_template("moderate.html",
+ alert=get_alert()
+ )
+
+@app.route("/pages/nick.html")
+def nick():
+ return render_template("nick.html", alert=get_alert() )
+
+@app.route("/pages/question.html")
+def question():
+ return render_template("question.html", alert=get_alert() )
+
+@app.route("/pages/quiz.html")
+def build():
+ return render_template("quiz.html", alert=get_alert() )