-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdata.py
More file actions
46 lines (34 loc) · 1.19 KB
/
data.py
File metadata and controls
46 lines (34 loc) · 1.19 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
import os
from flask import Flask, render_template, request, flash, redirect, session, url_for
from flask_debugtoolbar import DebugToolbarExtension
from model import connect_to_db, db, Tree, TreeSpecies
app = Flask(__name__)
FLASK_TOKEN = os.environ.get('FLASK_TOKEN')
app.secret_key = FLASK_TOKEN
def tree_facts(name):
"""Query Tree species information"""
tree_dict={
'platanus':'Platanus x hispanica',
'prunus': 'Prunus cerasifera',
'magnolia':'Magnolia grandiflora',
'tristan':'Tristaniopsis laurina',
'gingko':'Ginkgo biloba'
}
sci_name = tree_dict[name]
print('++++++++__sci_name__++++++++++++',sci_name)
tree = TreeSpecies.query.filter(TreeSpecies.sci_name==sci_name).first()
facts = (tree.sci_name,
tree.common_name,
tree.shape,
tree.factoid,
tree.margin,
tree.venation,
tree.image)
print('xxxxxxxxxxx__facts__xxxxxxxxxxxxxxx',facts)
return facts
if __name__ == "__main__":
app.debug = True
connect_to_db(app)
# Use the DebugToolbar
DebugToolbarExtension(app)
app.run(host="0.0.0.0")