-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathapp.py
39 lines (28 loc) · 1 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
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def main():
return render_template('app.html')
@app.route('/send', methods=['POST'])
def send(sum=sum):
if request.method == 'POST':
num1 = request.form['num1']
num2 = request.form['num2']
operation = request.form['operation']
if operation == 'add':
sum = float(num1) + float(num2)
return render_template('app.html', sum=sum)
elif operation == 'subtract':
sum = float(num1) - float(num2)
return render_template('app.html', sum=sum)
elif operation == 'multiply':
sum = float(num1) * float(num2)
return render_template('app.html', sum=sum)
elif operation == 'divide':
sum = float(num1) / float(num2)
return render_template('app.html', sum=sum)
else:
return render_template('app.html')
if __name__ == ' __main__':
app.debug = True
app.run()