-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
122 lines (101 loc) · 3.69 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 9 11:22:08 2020
@author: School
"""
from flask import Flask,render_template,request,redirect
app = Flask(__name__)
import sys
sys.path.append("/abunator_main/")
import counter
import setters
import sqlMethods
import Examine
import result
PathList = [0]
@app.route('/start/<key>',methods = ['GET'])
def starter(key):
if 'true' in key and len(key) == 14:
global linker
linker = key
setters.setPathList()
setters.setColumnList()
setters.setQuestionList()
setters.setSQLList()
column = Examine.getCulumn()
question = Examine.getQuestion(column)
counter.ColumnList.append(column)
counter.QuestionList.append(question)
return render_template('/main.html',\
key = linker,\
# question = sqlMethods.questionVerse(sqlMethods.getCalm(counter.ColumnList)))
question = question)
@app.route('/return/<key>',methods = ['GET'])
def initial(key):
linker = key
return redirect('https://abunatorroute.azurewebsites.net/return/' + linker)
#@app.route('/main',methods = ['GET'])
#def procedure():
# return render_template('/main.html',\count = count ,\
# question = sqlMethods.questionVerse(sqlMethods.getCalm(counter.ColumnList)))
@app.route('/main/<key>', methods = ['POST'])
def branch(key):
linker = key
answer = request.form.get("answer")
path = request.form.get("path")
column = counter.ColumnList[len(counter.ColumnList)-1]
question = counter.QuestionList[len(counter.QuestionList)-1]
del PathList[len(PathList)-1]
PathList.append(int(path))
counter.ListMaker(int(answer),column,question)
count = counter.GetCount()
if PathList[len(PathList)-1] == 1 and counter.QuestionList[len(counter.QuestionList)-1] == counter.QuestionList[0]:
return redirect('https://abunatorroute.azurewebsites.net/return/' + linker)
elif PathList[len(PathList)-1] == 1:
del counter.SQLList [len(counter.SQLList)-1]
del counter.SQLList [len(counter.SQLList)-1]
del counter.ColumnList [len(counter.ColumnList)-1]
del counter.QuestionList [len(counter.QuestionList)-1]
return render_template('/main.html',\
key = linker,\
question = counter.QuestionList[len(counter.QuestionList)-1])
elif count == 1:
resultList = result.result()
no = resultList[0]
name = resultList[1]
dealing = resultList[2]
rank = resultList[3]
userNo = linker[0:10]
result.insert(userNo,name)
return render_template('/result.html',\
number = no,\
name = name,\
dealing = dealing,\
rank = rank,\
key = linker)
elif count == 0 or len(counter.ColumnList) >= 50:
return render_template('/unknown.html',
key = linker)
elif count >= 2:
column = Examine.getCulumn()
question = Examine.getQuestion(column)
if not question in counter.QuestionList:
counter.ColumnList.append(column)
counter.QuestionList.append(question)
return render_template('/main.html',\
key = linker,\
question = question)
else:
while question in counter.QuestionList:
column = Examine.getCulumn()
question = Examine.getQuestion(column)
counter.ColumnList.append(column)
counter.QuestionList.append(question)
return render_template('/main.html',\
key = linker,\
question = question)
else:
return render_template('/error.html',\
key = linker)
if __name__ == "__main__":
app.run(debug=True, port=5000, threaded=True)