2019-10-23 10:28:03 +02:00
|
|
|
from datetime import datetime, timedelta
|
2019-10-13 20:35:48 +02:00
|
|
|
from django.shortcuts import render
|
2019-10-20 21:39:03 +02:00
|
|
|
from . import plot
|
2019-10-13 20:35:48 +02:00
|
|
|
|
2019-10-20 21:39:03 +02:00
|
|
|
def index_view(request):
|
2019-10-23 10:28:03 +02:00
|
|
|
start_time = datetime.now() - timedelta(hours=24)
|
|
|
|
plot_temp = plot.temperature(start_time)
|
|
|
|
plot_humidity = plot.humidity(start_time)
|
|
|
|
plot_pressure = plot.pressure(start_time)
|
2019-10-20 21:39:03 +02:00
|
|
|
return render(request, "collector/index.html",
|
|
|
|
context={'plot_temp': plot_temp,
|
|
|
|
'plot_humidity': plot_humidity,
|
|
|
|
'plot_pressure': plot_pressure})
|
2019-10-24 22:35:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
def history_view(request, hours):
|
|
|
|
start_time = datetime.now() - timedelta(hours=hours)
|
|
|
|
plot_temp = plot.temperature(start_time)
|
|
|
|
plot_humidity = plot.humidity(start_time)
|
|
|
|
plot_pressure = plot.pressure(start_time)
|
|
|
|
return render(request, "collector/index.html",
|
|
|
|
context={'plot_temp': plot_temp,
|
|
|
|
'plot_humidity': plot_humidity,
|
|
|
|
'plot_pressure': plot_pressure})
|