-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
67 lines (55 loc) · 1.58 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
import os
from flask import (
Flask,
render_template,
jsonify,
request,
redirect)
from sqlalchemy import MetaData
from sqlalchemy import inspect
from sqlalchemy import Table
import pandas as pd
#################################################
# Flask Setup
#################################################
app = Flask(__name__)
db_path = "sqlite:///threatened_species.db"
from flask_sqlalchemy import SQLAlchemy
app.config['SQLALCHEMY_DATABASE_URI'] = db_path
db = SQLAlchemy(app)
@app.route("/")
def home():
return render_template("index.html")
# return render_template("index.html")
@app.route("/fusionmap")
def fusionmap():
return render_template("fusionmap.html")
@app.route("/heatmap")
def heatmap():
return render_template("heatmap.html")
@app.route("/mapboxkey")
def mapboxkey():
return str(os.environ.get("MAPBOX_TOKEN"))
@app.route("/scatterplot")
def scatterplot():
return render_template("scatterplot.html")
@app.route("/data")
def dataTable():
return render_template("dataTable.html")
@app.route("/threatened_species")
def get_otu_ids():
# defining metatdata
metadata = MetaData()
metadata.reflect(bind=db.engine)
# getting the samples table
samples = metadata.tables['Threatened_Species']
# converting table into something we can actually use
res = db.session.query(samples).all()
# Final data
data = res
# It is possible to get the headings using VVV
# print(res[0].keys())
#getting the data
return jsonify(data[0 :])
if __name__ == "__main__":
app.run(debug=True)