Repository navigation
Expand file tree
/
Copy pathhomepage.py
More file actions
80 lines (56 loc) · 2.3 KB
/
Copy pathhomepage.py
File metadata and controls
80 lines (56 loc) · 2.3 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
import os
import subprocess
from flask import Flask, render_template, request
from variables import selected_features
app = Flask(__name__)
@app.route("/")
def homepage():
return render_template("homepage.html", name="Homepage")
@app.route("/describe", methods=["POST", "GET"])
def describe():
table = False
gryffindor = False
hufflepuff = False
ravenclaw = False
slytherin = False
if request.method == "POST":
subprocess.call(["make webdescribe"], shell=True)
# get html table
if os.path.isfile("templates/describe_table.html"):
table = True
if os.path.isfile("templates/describe_table_Gryffindor.html"):
gryffindor = True
if os.path.isfile("templates/describe_table_Hufflepuff.html"):
hufflepuff = True
if os.path.isfile("templates/describe_table_Ravenclaw.html"):
ravenclaw = True
if os.path.isfile("templates/describe_table_Slytherin.html"):
slytherin = True
return render_template("describe.html", table=table, gryffindor=gryffindor, hufflepuff=hufflepuff, ravenclaw=ravenclaw, slytherin=slytherin)
@app.route("/histogram", methods=["POST", "GET"])
def histogram():
image_path = os.path.join("static", "Image", "hist")
if request.method == "POST":
subprocess.call(["make webhistogram"], shell=True)
image_names = os.listdir(image_path)
image_names.sort()
images = [os.path.join(image_path, i) for i in image_names]
return render_template("histogram.html", images=images)
@app.route("/scatter", methods=["POST", "GET"])
def scatter():
image_path = os.path.join("static", "Image", "scatter")
if request.method == "POST":
subprocess.call(["make webscatter"], shell=True)
image_names = os.listdir(image_path)
image_names.sort()
images = [os.path.join(image_path, i) for i in image_names]
return render_template("scatter.html", images=images)
@app.route("/pair", methods=["POST", "GET"])
def pair():
image_path = os.path.join("static", "Image", "pair")
if request.method == "POST":
subprocess.call(["make webpair"], shell=True)
image_names = os.listdir(image_path)
image_names.sort()
images = [os.path.join(image_path, i) for i in image_names]
return render_template("pair.html", images=images, features=selected_features)