summaryrefslogtreecommitdiff
path: root/get_questions.py
diff options
context:
space:
mode:
authorTuomas Klavér <tklavr@local>2023-11-20 02:04:12 +0200
committerTuomas Klavér <tklavr@local>2023-11-20 02:04:12 +0200
commitd13d4860f3d5b51d659379aa8a38742bfe49bf37 (patch)
treeeaf65876d9a4497f282dab300007338144c53001 /get_questions.py
parent4724a8667371abcf8b0a5a7355a7c2588841c135 (diff)
Questions now shows up. DB -> JSON -> JS -> DOM
Diffstat (limited to 'get_questions.py')
-rw-r--r--get_questions.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/get_questions.py b/get_questions.py
new file mode 100644
index 0000000..496b99a
--- /dev/null
+++ b/get_questions.py
@@ -0,0 +1,18 @@
+from app import app
+from flask import render_template, session, request, redirect, jsonify
+import db_actions as D
+
+
+@app.route("/get_questions",methods=["GET"])
+def get_questions_by_id():
+ if "quiz_id" not in session.keys():
+ return "KUOLETTAVA: Sessiota / kyselmä id:tä ei ole"
+
+ results = D.get_questions(session['quiz_id'])
+ r={}
+ names=['i','q','n','p','a']
+ for i in range(len(results)):
+ r[i]={}
+ for j in range(len(results[i])):
+ r[i][names[j]]=results[i][j]
+ return (jsonify(r))