Exemplo n.º 1
0
 def get(self):
     result= datastore.last_n(1)[0]
     loader = tornado.template.Loader('static')
     result = loader.load('index.html').generate(
         temperature=result['temperature'],
         humidity=result['humidity'],
         reportdate=result['date'])
     self.write(result)
Exemplo n.º 2
0
def update_chart(path):
    datapoints = datastore.last_n(30)
    if not datapoints:
        return
    datapoints = datapoints[::-1]
    times = [ p['date'] for p in datapoints ]
    temperatures = [ p['temperature'] for p in datapoints ]
    humidities = [ p['humidity'] for p in datapoints ]

    chart = pygal.Line(
        fill=True,
        style=LightGreenStyle,
        legend_at_bottom=True,
        spacing=10,
        height=400,
        range=[0.0, 100.0])
    chart.value_formatter = lambda x: "%.0f" % x
    chart.x_labels = _create_labels(times)
    chart.add('°C', temperatures)
    chart.add('%', humidities, secondary=True)
    chart.render_to_file(path)
Exemplo n.º 3
0
 def get(self):
     result= datastore.last_n(1)[0]
     self.write( {'temperature': result['temperature'], 'humidity': result['humidity'] })