Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions app/routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from flask import jsonify, request
import json
from app import app


Expand All @@ -8,20 +9,23 @@ def index():
return "Hello, World!"


@app.route('/question/<level>', methods=['GET'])
def question(level: int):
@app.route('/question/<int:level>', methods=['GET'])
def question(level:int):
"""
GET request to get a question for the user based on their current level
"""

qns = {}
f=open("./gameinfo.json", "r")
qn = json.load(f)["questions"][level-1]

if request.method == 'GET':
qns = {
"question": None,
"options": None,
"optionCount":None,
"xpOnSuccess": None,
"Level": level,
"type":qn["type"],
"question": qn["question"],
"options":qn["options"],
"answer": qn["answer"],
"xpOnSuccess": qn["xpOnSuccess"],
}

return jsonify(qns)

31 changes: 31 additions & 0 deletions gameinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"questions":[
{
"id": 0,
"type": "IMG2WRD",
"question":"https://images.ctfassets.net/vz6nkkbc6q75/1Mu1ljM84WXagx5muIxmyy/e8a5ff4bccbd39d63bf12b2892aeafc7/Hello_2BSmall_2B1.gif?w=&q=80&fm=webp",
"options":["hello","thank you","welcome","how"],
"answer":0,
"xpOnSuccess":100

},
{
"id": 1,
"type": "IMG2WRD",
"question":"https://images.ctfassets.net/vz6nkkbc6q75/2wHIqJmIziBv5PODZThVlu/9c46b5c9fe7666aa767d2d48c6bf8095/Thank_2BYou_2BSmaller.gif?w=&q=80&fm=webp",
"options":["hello","thank you","welcome","how"],
"answer":1,
"xpOnSuccess":100

},
{
"id": 2,
"type": "WRD2IMG",
"question":"Morning",
"options":["https://t.ly/bTx_9","https://t.ly/q3OHz","https://t.ly/w7gmO","https://t.ly/u6tj3"],
"answer":1,
"xpOnSuccess":100

}
]
}