-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
87 lines (61 loc) · 2.15 KB
/
main.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
from flask import Flask
from flask_restful import Api, Resource
from operations import linearReg, decisionTree, getLastWeek, getAllCategories, getAllSubCategories, getAllTypes, \
getAllColors, getAllClothes, frequencyOfClothes
app = Flask(__name__)
api = Api(app)
class regression(Resource):
def get(self):
json = {
'temperature': linearReg('temperature'),
'wind': linearReg('wind'),
'humidity': linearReg('humidity'),
'pressure': linearReg('pressure'),
}
return json
class classify(Resource):
def get(self):
json = {
'generalWeatherResult': decisionTree(linearReg('temperature'), linearReg('wind'), linearReg('humidity'),
linearReg('pressure'), ),
}
return json
class getLastWeekWeather(Resource):
def get(self):
json = {"oneWeek": getLastWeek()}
return json
class getAllCategories_(Resource):
def get(self):
json = {"categories": getAllCategories()}
return json
class getAllSubCategories_(Resource):
def get(self):
json = {"subCategories": getAllSubCategories()}
return json
class getAllTypes_(Resource):
def get(self):
json = {"types": getAllTypes()}
return json
class getAllColors_(Resource):
def get(self):
json = {"colors": getAllColors()}
return json
class getAllClothes_(Resource):
def get(self):
json = {"clothes": getAllClothes()}
return json
class getAllClothStatus_(Resource):
def get(self, amount):
json = {"clothesStatus": frequencyOfClothes(amount)}
return json
api.add_resource(regression, "/linear")
api.add_resource(classify, "/decisionTree")
api.add_resource(getLastWeekWeather, "/weakly")
api.add_resource(getAllCategories_, "/categories")
api.add_resource(getAllSubCategories_, "/subCategories")
api.add_resource(getAllTypes_, "/types")
api.add_resource(getAllColors_, "/colors")
api.add_resource(getAllClothes_, "/clothes")
api.add_resource(getAllClothStatus_,"/clothesStatus/<int:amount>")
if __name__ == '__main__':
app.run('0.0.0.0', 5000)