-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
58 lines (43 loc) · 1.34 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
#ec2-password
from flask import Flask, render_template, request
import math, ast
app = Flask(__name__)
class MyMath():
def __init__(self) -> None:
self.num_list = []
def average(self) -> float:
sum = 0
count = 0
for i in self.num_list:
sum = sum + float(i)
count = count + 1
return (sum / count)
def stddev(self) -> float:
step2 = []
step3 = 0.0
sum = 0
count = 0
for i in self.num_list:
sum = sum + float(i)
count = count + 1
mean = (sum / count)
for i in self.num_list:
j = pow((i - mean),2)
step2.append(j)
for k in step2:
step3 += k
sd = math.sqrt(step3 / count)
return sd
@app.route('/')
def index():
return render_template('index.html')
@app.route('/result',methods=('GET','POST'))
def result():
if request.method == 'POST':
MMObj = MyMath()
MMObj.num_list = ast.literal_eval("[" + request.form['numlist'] + "]")
#MMObj.num_list = [1,2,3,4,5,6,7,8,9,10]
#print(MMObj.num_list)
return render_template('result.html',numlist=MMObj.num_list, max=max(MMObj.num_list),average=MMObj.average(),stddev=MMObj.stddev())
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')