-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
97 lines (86 loc) · 3.93 KB
/
main.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
"""
author : Mrinal Pandey
Priti Chattopadhyay
"""
#importing necessary classes and packages
from returnquestion import ReturnQuestion
from sheet_creator import SheetCreator
from additiondriver import AdditionErrorClassifier
from subtractiondriver import SubtractionErrorClassifier
from multiplicationdriver import MultiplicationErrorClassifier
from divisiondriver import DivisionErrorClassifier
from AdditionWorking import *
from MultiplicationWorking import *
import flask
from flask import request, jsonify, render_template
#Configuring the Flask Application
app = flask.Flask(__name__)
app.config["DEBUG"] = True
@app.route('/', methods = ['GET'])
def hello():
return render_template('index.html')
#format to call: "<base_url>/question?uid=<user_uid>&row=<next_row>&sno=<sheet_number>"
"""
sheet_number = 1 for Addition, 2 for subtraction, 3 for multiplication and 4 for division
"""
@app.route('/question', methods = ['GET', 'POST'])
def returnNextQuestion():
uid = request.args['uid']
row_number = request.args['row']
sheet = request.args['sno']
return_question = ReturnQuestion(uid, row_number, sheet)
return jsonify(return_question.getNextQuestion())
#format to call: "<base_url>/sheet?uid=<user_uid>"
@app.route('/sheet', methods = ['GET', 'POST'])
def returnNewSheet():
uid = request.args['uid']
new_sheet = SheetCreator()
return jsonify(new_sheet.create_sheet(uid))
#format to call: "<base_url>/addition?uid=<user_uid>&row=<current_row>&answer=<answer_by_user>"
@app.route('/addition', methods = ['GET', 'POST'])
def addition():
uid = request.args['uid']
row_number = request.args['row']
answer_by_user = request.args['answer']
addition_error_classifier = AdditionErrorClassifier(uid, row_number, answer_by_user)
return jsonify(addition_error_classifier.checkIfCorrect())
#format to call: "<base_url>/subtraction?uid=<user_uid>&row=<current_row>&answer=<answer_by_user>"
@app.route('/subtraction', methods = ['GET', 'POST'])
def subtraction():
uid = request.args['uid']
row_number = request.args['row']
answer_by_user = request.args['answer']
subtraction_error_classifier = SubtractionErrorClassifier(uid, row_number, answer_by_user)
return jsonify(subtraction_error_classifier.checkIfCorrect())
#format to call: "<base_url>/multiplication?uid=<user_uid>&row=<current_row>&answer=<answer_by_user>"
@app.route('/multiplication', methods = ['GET', 'POST'])
def multiplication():
uid = request.args['uid']
row_number = request.args['row']
answer_by_user = request.args['answer']
multiplication_error_classifier = MultiplicationErrorClassifier(uid, row_number, answer_by_user)
return jsonify(multiplication_error_classifier.checkIfCorrect())
#format to call: "<base_url>/division?uid=<user_uid>&row=<current_row>&answer=<answer_by_user>"
@app.route('/division', methods = ['GET', 'POST'])
def division():
uid = request.args['uid']
row_number = request.args['row']
answer_by_user = request.args['answer']
division_error_classifier = DivisionErrorClassifier(uid, row_number, answer_by_user)
return jsonify(division_error_classifier.checkIfCorrect())
#format to call: "<base_url>/addition-working?uid=<user_uid>&number1=<first_number>&number2=<second_number>"
@app.route('/addition-working', methods = ['GET', 'POST'])
def workingOfAddition():
uid = request.args['uid']
number1 = request.args['number1']
number2 = request.args['number2']
return jsonify(addition_working(uid, number1, number2))
#format to call: "<base_url>/multiplication-working?uid=<user_uid>&number1=<first_number>&number2=<second_number>"
@app.route('/multiplication-working', methods = ['GET', 'POST'])
def workingOfMultiplication():
uid = request.args['uid']
number1 = request.args['number1']
number2 = request.args['number2']
return jsonify(multiplication_working(uid, number1, number2))
if __name__ == '__main__':
app.run()