generate random data. commented out as it kills every browser.
authorgregor herrmann <gregor@toastfreeware.priv.at>
Sun, 3 Jun 2018 15:35:09 +0000 (17:35 +0200)
committergregor herrmann <gregor@toastfreeware.priv.at>
Sun, 3 Jun 2018 15:35:09 +0000 (17:35 +0200)
web/seepark_web.py

index 912b09aa1646d46fc869d9e98e5869f24f19fbe8..f95a05468712046a87eb0258f50300c6a4b85050 100644 (file)
@@ -1,4 +1,6 @@
 from flask import Flask, render_template, jsonify
 from flask import Flask, render_template, jsonify
+from random import uniform
+import time
 app = Flask(__name__)
 
 @app.route("/data")
 app = Flask(__name__)
 
 @app.route("/data")
@@ -9,6 +11,32 @@ def data():
         '0316a21383ff': [27, 32, 26, 29, 30, 31],
         '0316a21383ff_x': [                       '2018-05-21 18:00:00', '2018-05-22 14:05:00', '2018-05-23 14:05:00', '2018-05-24 14:05:02', '2018-05-25 14:05:01', '2018-05-27 14:05:01'],
         }
         '0316a21383ff': [27, 32, 26, 29, 30, 31],
         '0316a21383ff_x': [                       '2018-05-21 18:00:00', '2018-05-22 14:05:00', '2018-05-23 14:05:00', '2018-05-24 14:05:02', '2018-05-25 14:05:01', '2018-05-27 14:05:01'],
         }
+
+#    years = 3
+#    granularity = 5 # minutes
+#    samples = 60/granularity * 24 * 365 * years # every "granularity" minutes for "years" years
+#    s4m   = []
+#    s4m_x = []
+#    s5m   = []
+#    s5m_x = []
+#    end   = time.time()
+#    start = end - samples * granularity * 60
+#
+#    for i in range(int(samples)):
+#        s4m.append(uniform(-10,30))
+#        s5m.append(uniform(-10,30))
+#        s4mt = uniform(start, end)
+#        s5mt = uniform(start, end)
+#        s4m_x.append(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(s4mt)))
+#        s5m_x.append(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(s5mt)))
+#
+#    data = {
+#        '0316a2193bff':   s4m,
+#        '0316a2193bff_x': s4m_x,
+#        '0316a21383ff':   s5m,
+#        '0316a21383ff_x': s5m_x,
+#        }
+
     return jsonify(data)
 
 
     return jsonify(data)