-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
103 lines (98 loc) · 3.05 KB
/
Copy pathapp.py
File metadata and controls
103 lines (98 loc) · 3.05 KB
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
101
102
103
from flask import Flask,jsonify,request,render_template, redirect, url_for
import statistics as st
import numpy as npy
import json as js
app = Flask(__name__,template_folder='template')
@app.route('/home/statistics/min_squares', methods=['POST'])
def page1():
array = []
for i in range(0,len(request.json['result'])):
array.append(request.json['result'][i.__str__()])
res = st.min_square(array,request.json['cant']['val'])
formatResult=[]
for i in range(len(res)):
formatResult.append({i:float("{0:.2f}".format(res[i]))})
return jsonify({"result":formatResult})
@app.route('/home/statistics/northwest_corner')
def northwest_corner():
test ={
"0":{
"0":5,
"1":2,
"2":7,
"3":3,
"4":80
},
"1":{
"0":3,
"1":6,
"2":6,
"3":1,
"4":30
},
"2":{
"0":6,
"1":1,
"2":2,
"3":4,
"4":60
},
"3":{
"0":4,
"1":3,
"2":6,
"3":6,
"4":45
},
"4":{
"0":70,
"1":40,
"2":70,
"3":35,
}
}
#res = mc.northwest_corner(test)
demand = npy.array([70, 40, 70, 35])
supply = npy.array([80, 30, 60, 45])
costs = npy.array([[5., 2., 7., 3.],
[3., 6., 6., 1.],
[6., 1., 2., 4.],
[4., 3., 6., 6.]])
res = st.northwest_corner(costs,supply,demand)
print(res)
return "s"
@app.route('/home/statistics/mean')
def mean():
res = st.mean([2, 3, 6, 8, 11])
return jsonify({"result": res})
@app.route('/home/statistics/median')
def median():
res = st.median([2, 3, 4, 4, 5, 5, 5, 6, 6])
return jsonify({"result": res})
@app.route('/home/statistics/typical_deviation')
def typical_deviation():
mean = st.mean([2, 3, 6, 8, 11])
res = st.typical_deviation(mean,[2, 3, 6, 8, 11])
return jsonify({"result": float("{0:.2f}".format(res))})
@app.route('/home/statistics/typical_deviation_table/<result>')
def view_typical_deviation_table(result):
return render_template('typical_deviation_table.html',res=result)
@app.route('/home/statistics/typical_deviation_table',methods=['GET','POST'])
def typical_deviation_table():
if request.method == "POST":
x_i = request.json['res']['x_i']
f_i = request.json["res"]['f_i']
res = st.typical_deviation_table([x_i,f_i])
data = { 'init_table':{
'x_i':x_i,
'f_i':f_i
},
'table_result':[res[0]],
'mean': res[1],
'deviation':res[2]}
return data;
@app.route('/home/statistics/typical_deviation_interval')
def typical_deviation_interval():
return render_template('typical_deviation.html')
if __name__ == '__main__':
app.run(debug=True,port=5000)