#!/usr/bin/python

import nilmdb
import json

# Start web app on a custom port
db = nilmdb.NilmDB("db")
server = nilmdb.Server(db, host = "127.0.0.1",
                       port = 12380,
                       embedded = False)
try:
    import yappi
    yappi.start()
    server.start(blocking = True)
finally:
    yappi.stop()
    stats = yappi.get_stats(sort_type=yappi.SORTTYPE_TTOT)
    from IPython import embed
    embed()
db.close()
