-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhems.py
executable file
·60 lines (47 loc) · 1.35 KB
/
hems.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
#!/usr/bin/python
from flask import Flask, render_template, jsonify
import random
import json
import DataMgr
import logging
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
production_W = 0
consumption_W = 0
app = Flask(__name__)
datamgr = DataMgr.DataMgr(aggregate_interval_s=3600)
@app.route('/')
def index():
return render_template('./page.html')
@app.route('/graphs.js')
def graphs():
return render_template('./graphs.js')
@app.route('/loading.js')
def loading():
return render_template('./loading.js')
@app.route('/data/production/live')
def data_production_live():
global datamgr
return jsonify(datamgr.get_production_W())
@app.route('/data/consumption/live')
def data_consumption_live():
global datamgr
return jsonify(datamgr.get_consumption_W())
@app.route('/data/vgrid/live')
def data_vgrid_live():
global datamgr
return jsonify(datamgr.get_V_grid())
@app.route('/data/latest_live_data')
def latest_live_data():
global datamgr
return jsonify(datamgr.get_latest_live_data())
@app.route('/data/last_day')
def get_last_day_aggregate_data():
global datamgr
return jsonify(datamgr.get_last_day_aggregate_data())
@app.route('/data/daily')
def get_last_365_days_aggregate():
global datamgr
return jsonify(datamgr.get_last_365_days_aggregate())
if __name__ == '__main__':
app.run(host="0.0.0.0", port=3000, debug=False)