-
Notifications
You must be signed in to change notification settings - Fork 942
/
Copy pathapp.py
33 lines (28 loc) · 1.17 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
from flask import Flask, render_template, request, jsonify
# from handle_calculation import calculate
app = Flask(__name__)
@app.route("/")
def home():
return render_template('form.html')
@app.route("/results", methods=['POST','GET'])
def predict():
if request.method == 'POST' and 'operand_1' in request.form and 'operand_2' in request.form and 'operator' in request.form:
operand_1 = float(request.form.get('operand_1'))
operand_2 = float(request.form.get('operand_2'))
operator = request.form.get('operator')
if(operand_2 == 0 and operator=='Division'):
result='Invalid_operation'
elif(operator == 'Addition'):
result = operand_1 + operand_2
elif(operator == 'Subtraction'):
result = operand_1 - operand_2
elif(operator == 'Multiplication'):
result = operand_1 * operand_2
elif(operator == 'Division'):
result = operand_1 / operand_2
else:
result = 'Invalid_Choice'
# result = calculate(operand_1, operand_2, operator)
return render_template("form.html",prediction_text=str(result))
if __name__ == '__main__':
app.run(debug=True)