-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
127 lines (98 loc) · 3.3 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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from flask import Flask, render_template, request, redirect, url_for, session
import mongo
import NormalModel
import KubeModel
import NormalFormat
import KubeFormat
app = Flask(__name__, static_url_path='/static')
app.debug = True
app.secret_key = "Nothing"
@app.route("/")
def index():
check = False
if "name" in session:
check = True
return render_template("index.html",check=check)
@app.route("/login")
def LoginPage():
if "name" in session:
return redirect("/dashboard")
return render_template("login.html")
@app.route("/dashboard")
def DashBoardPage():
if "name" in session:
StatData,TableData = mongo.ProjectStats(session['email'])
return render_template("/Dashboard/light/index.html",name=session['name'],email=session['email'],StatData=StatData,TableData=TableData)
return redirect("/")
@app.route("/logout")
def LogOut():
session.clear()
return redirect("/")
@app.route("/strategy")
def Strategy():
if "name" in session:
return render_template("/Dashboard/light/strategy.html",name=session['name'],email=session['email'])
return redirect("/")
@app.errorhandler(404)
def error404(error):
return render_template('404.html'), 404
# Ajax Function
@app.route('/login_action', methods=['POST'])
def login_action():
email = request.form['email']
password = request.form['password']
print(email, password)
data = {}
result = mongo.Login(email,password)
if result['check']:
session['email'] = email
session['name'] = result['name']
data['check'] = True
data['link'] = "/dashboard"
return data
@app.route('/sign_action', methods=['POST'])
def sign_action():
name = request.form['name']
email = request.form['email']
password = request.form['password']
print(name,email,password)
data = {}
if mongo.Register(email,name,password):
session['email'] = email
session['name'] = name
data['check'] = True
data['link'] = '/dashboard'
return data
@app.route('/strategy_action',methods=['POST'])
def StrategyAction():
ProjectName = request.form['ProjectName']
LineCode = request.form['LineCode']
Language = request.form['Language']
Cloud = request.form['Cloud']
Function = request.form['Function']
print(ProjectName,LineCode,Language,Cloud,Function)
result = KubeModel.KubePrediction(Language,Function,LineCode)
print(result)
Format = KubeFormat.Formatting(result)
mongo.Project(ProjectName,LineCode,Language,Cloud,Function,result,session['email'])
data = {}
data['check'] = True
data['output'] = result
data['Format'] = Format
return data
@app.route('/strategy_normal',methods=['POST'])
def NormalStrategy():
ProjectName = request.form['ProjectName']
LineCode = request.form['LineCode']
Language = request.form['Language']
Function = request.form['Function']
result = NormalModel.NormalPrediction(Language,Function,LineCode)
Format = NormalFormat.Formatting(result)
mongo.NormalProject(ProjectName,LineCode,Language,Function,result,session['email'])
data = {}
data['check'] = True
data['output'] = result
data['Format'] = Format
return data
if __name__ == "__main__":
app.run(host='0.0.0.0',port=5000)