pass timespan (in days) to our /data route via GET
authorgregor herrmann <gregor@toastfreeware.priv.at>
Mon, 4 Jun 2018 16:43:27 +0000 (18:43 +0200)
committergregor herrmann <gregor@toastfreeware.priv.at>
Mon, 4 Jun 2018 16:44:24 +0000 (18:44 +0200)
web/seepark_web.py
web/static/seepark_web.js

index 0a1aa34a7f502fa28e4eb73dde60074dc173daa0..fa08f12480bf96d5a6ace7283fdf1b579efd1b7c 100644 (file)
@@ -3,11 +3,11 @@ from random import uniform
 import time
 app = Flask(__name__)
 
-@app.route("/data")
-def data():
+@app.route('/data/', defaults={'timespan': 1})
+@app.route("/data/<int:timespan>", methods=['GET'])
+def data(timespan):
 
-    timespan = 1                             # days
-    granularity = 5 * timespan               # (every) minute(s)
+    granularity = 5 * timespan               # (every) minute(s) per day
     samples = 60/granularity * 24 * timespan # per hour over whole timespan
     s4m   = []
     s4m_x = []
index ce4226e6af4f1cd6d628d674a9998d16280ee100..ca30ac17a5fcf3f2257818d26c08b7c4e94f9062 100644 (file)
@@ -7,7 +7,7 @@ var chart = c3.generate({
                text: 'Der See'
        },
        data: {
-               url: '/data',
+               url: '/data/', // redirects to /data/1
                mimeType: 'json',
                xs: {
                        '0316a2193bff': '0316a2193bff_x',