-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
42 lines (35 loc) · 1.14 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
__author__ = "Jeremy Nelson"
from flask import Flask, render_template
from flask_flatpages import FlatPages
from reports import report_router
app = Flask(__name__)
app.config['FLATPAGES_EXTENSION'] = ['.md']
app.config['FLATPAGES_ROOT'] = 'doc'
pages = FlatPages(app)
@app.template_filter("pretty_num")
def nice_number(raw_number):
return "{:,}".format(int(raw_number))
@app.route("/reports/")
@app.route("/reports/<path:name>.html")
def reporting(name=None):
if name is None:
return render_template("reports/index.html")
else:
data = report_router(name)
return render_template("reports/{}.html".format(name),
data=data)
@app.route("/<path:name>")
def page(name):
doc = pages.get_or_404(name)
#doc = pages.get(name)
return render_template("page.html", page=doc)
@app.route("/")
def home():
total_items, total_instances = 0, 0
for page in pages:
total_items += int(page.meta.get("bf_items"))
total_instances += int(page.meta.get("bf_instances"))
return render_template("index.html",
pages=pages,
total_items=total_items,
total_instances=total_instances)