-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
52 lines (45 loc) · 1.33 KB
/
app.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from flask import Flask,render_template,request
from main import firebase
from flask import redirect
app = Flask(__name__)
db=firebase.database()
#Global Varible
global i
i=0
points=0
data=db.child('quizz').child('questions').get()
@app.route('/')
def hello_world():
try:
global i
q=data.val()[i]
question=q['question']
option_a=q['answers'][0]
option_b=q['answers'][1]
option_c=q['answers'][2]
option_d=q['answers'][3]
return render_template('index.html',Question=question,Option_a=option_a,Option_b=option_b,Option_c=option_c,Option_d=option_d)
except:
print(Exception)
return "thank you"
@app.route('/action-submit',methods=['POST','GET'])
def submit():
try:
if request.method=='GET':
global i
selectedValue=request.args.get('answer')
index=data.val()[i]['correctIndex']
test=data.val()[i]['answers'][index]
print(test)
if(selectedValue==data.val()[i]['answers'][index]):
global points
points=points+1
print(points,'points')
i=i+1
return hello_world()
except:
print('thank you')
def click():
print('click')
if __name__ == '__main__':
app.run()