forked from nirmalya8/CalculateAndConvert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
100 lines (86 loc) · 3.02 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
from flask import *
app = Flask(__name__,static_folder="assets")
@app.route('/')
def homepage():
return render_template('index.html')
@app.route('/index.html')
def homepage2():
return render_template('index.html')
#this part will be in infix to postfix app route
@app.route('/InfixtoPostfix.html')
def showinftopost():
return render_template("InfixtoPostfix.html")
@app.route('/InfixtoPostfix.html/show',methods=['POST'])
def send():
from inftopost import inf_to_post as itf
s = request.form['x']
obj=itf()
l=[]
l,result=obj.infixtopostfix(s)
if (result==False):
result = "Wrong input given, Follow directions of use given above"
return render_template('InfixtoPostfix.html',results = result,l=l)
#this part is for the postfix to infix app route
@app.route('/PostfixtoInfix.html')
def showposttoinf():
return render_template("PostfixtoInfix.html")
@app.route('/PostfixtoInfix.html/show',methods=['POST'])
def postinfshow():
from posttoinf import post_to_inf as pti
s = request.form['x']
obj1=pti()
r = []
#r[:] =s
for i in s:
r.append(i)
l,result=obj1.getInfix(r)
if (result==False):
result = "Wrong Input, Check Directions of use and try again"
return render_template('PostfixtoInfix.html',results = result,l=l)
#the following part is for Infix to Prefix
@app.route('/InfixtoPrefix.html')
def showinftopre():
return render_template("InfixtoPrefix.html")
@app.route('/InfixtoPrefix.html/show',methods=['POST'])
def send2():
from inftopre import infix_to_prefix as intpr
obj2 = intpr()
expr=request.form['x']
rev=""
rev=obj2.reverse(expr)
#print(rev)
l,result=obj2.infixtoprefix(rev)
if (result!=False):
prefix=obj2.reverse(result)
return render_template('PostfixtoInfix.html',results = prefix,l=l)
else :
return render_template('PostfixtoInfix.html',results = "Wrong Input, Check Directions of Use and try again",l=[])
#this part is for prefix to infix
@app.route('/PrefixtoInfix.html')
def pretoinf():
return render_template("PrefixtoInfix.html")
@app.route('/PrefixtoInfix.html/show',methods=['POST'])
def send3():
from pretoinf import prefixtoinfix as prtin
obj3 = prtin()
l = []
expr=request.form['x']
l,result = obj3.prefixToInfix(expr)
if (result!=False):
return render_template('PostfixtoInfix.html',results = result,l=l)
else :
return render_template('PostfixtoInfix.html',results = "Wrong Input, Check Directions of Use and try again",l=[])
#Calculator
@app.route('/Calculator.html')
def showeval():
return render_template('Calculator.html')
@app.route('/Calculator.html/show',methods = ['POST'])
def outcalc():
from eval import evaluate as ev
obj = ev()
a = request.form['a']
s = request.form['s']
res = ev.calc(a,s)
return render_template('Calculator.html',results = res)
if __name__ == "__main__":
app.run(debug=True)