from flask import Flask
from flask import render_template
from flask.ext.pymongo import PyMongo
import database
from bson.json_util import dumps
from datetime import datetime

app = Flask("log_db")
mongo = PyMongo(app)
app.debug = True

@app.route('/')
def overview():
    return render_template('index.html')

@app.route('/all_items')
def all_items():
    return dumps(database.all_log_items(mongo.db))

if __name__ == "__main__":
    app.run()
from flask import Flask
from flask import render_template
from flask.ext.pymongo import PyMongo
import database
from bson.json_util import dumps
from datetime import datetime

app = Flask("log_db")
mongo = PyMongo(app)
app.debug = True

@app.route("/")
def overview():
    return render_template("index.html")

@app.route("/all_items")
def all_items():
    return dumps(database.all_log_items(mongo.db))

@app.route("/stats_per_day/<int:date>")
def stats_per_day(date):
    d = str(date)
    day = datetime(int(d[:4]), int(d[4:6]), int(d[6:]))
    log_items = database.get_stats_per_day(mongo.db, day)
    return dumps(log_items)

if __name__ == "__main__":
    app.run()
add stats-per-day route