-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
50 lines (41 loc) · 1.31 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
from flask import Flask, flash, redirect, render_template, request, session, abort, send_from_directory
import decision_tree_diabetes as dt
import json
import os
app = Flask(__name__)
app.config['DEBUG'] = True
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
@app.route('/')
def index():
return render_template('index.html')
@app.route('/model')
def model():
return render_template('model.html')
@app.route('/dataset')
def dataset():
return render_template('dataset.html')
@app.route('/train', methods=['POST'])
def train():
result = dt.run(request.json)
print(result)
return json.dumps(result)
@app.route('/predict', methods=['POST'])
def predict():
result = dt.predict(request.json)
return json.dumps(result)
@app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'), 'favicon.ico', mimetype='image/vnd.microsoft.icon')
@app.after_request
def add_header(r):
"""
Add headers to both force latest IE rendering engine or Chrome Frame,
and also to cache the rendered page for 10 minutes.
"""
r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
r.headers["Pragma"] = "no-cache"
r.headers["Expires"] = "0"
r.headers['Cache-Control'] = 'public, max-age=0'
return r
if __name__ == "__main__":
app.run()