0
lab_app.db
Normal file
0
lab_app.db
Normal file
Binary file not shown.
@ -1,22 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Static page</title>
|
||||
<!-- Mobile Specific Metas
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- FONT
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
|
||||
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
|
||||
<!-- CSS
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
|
||||
<link rel="stylesheet" href="/static/css/normalize.css">
|
||||
<link rel="stylesheet" href="/static/css/skeleton.css">
|
||||
<!-- Favicon
|
||||
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
|
||||
<link rel="icon" type="/static/image/png" href="images/favicon.png">
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ message }}</h1>
|
||||
</body>
|
||||
</html>
|
BIN
pi_temp.db
Executable file
BIN
pi_temp.db
Executable file
Binary file not shown.
@ -53,22 +53,18 @@ app = Flask(__name__)
|
||||
app.debug = True # Make this False if you are no longer debugging
|
||||
|
||||
@app.route("/")
|
||||
def hello():
|
||||
return "Hello World!"
|
||||
|
||||
@app.route("/lab_temp")
|
||||
def lab_temp():
|
||||
import sys
|
||||
import Adafruit_DHT
|
||||
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.AM2302, 17)
|
||||
temperature = temperature * 9/5.0 + 32
|
||||
if humidity is not None and temperature is not None:
|
||||
return render_template("lab_temp.html",temp=temperature,hum=humidity)
|
||||
return render_template("live.html",temp=temperature,hum=humidity)
|
||||
else:
|
||||
return render_template("no_sensor.html")
|
||||
|
||||
@app.route("/lab_env_db", methods=['GET']) #Add date limits in the URL #Arguments: from=2015-03-04&to=2015-03-05
|
||||
def lab_env_db():
|
||||
@app.route("/history", methods=['GET']) #Add date limits in the URL #Arguments: from=2015-03-04&to=2015-03-05
|
||||
def pi_temp_db():
|
||||
temperatures, humidities, timezone, from_date_str, to_date_str = get_records()
|
||||
|
||||
# Create new record tables so that datetimes are adjusted back to the user browser's time zone.
|
||||
@ -82,9 +78,9 @@ def lab_env_db():
|
||||
local_timedate = arrow.get(record[0], "YYYY-MM-DD HH:mm").to(timezone)
|
||||
time_adjusted_humidities.append([local_timedate.format('YYYY-MM-DD HH:mm'), round(record[2],2)])
|
||||
|
||||
print "rendering lab_env_db.html with: %s, %s, %s" % (timezone, from_date_str, to_date_str)
|
||||
print "rendering history.html with: %s, %s, %s" % (timezone, from_date_str, to_date_str)
|
||||
|
||||
return render_template("lab_env_db.html", timezone = timezone,
|
||||
return render_template("history.html", timezone = timezone,
|
||||
temp = time_adjusted_temperatures,
|
||||
hum = time_adjusted_humidities,
|
||||
from_date = from_date_str,
|
||||
@ -135,7 +131,7 @@ def get_records():
|
||||
from_date_utc = arrow.get(from_date_obj, timezone).to('Etc/UTC').strftime("%Y-%m-%d %H:%M")
|
||||
to_date_utc = arrow.get(to_date_obj, timezone).to('Etc/UTC').strftime("%Y-%m-%d %H:%M")
|
||||
|
||||
conn = sqlite3.connect('lab_app.db')
|
||||
conn = sqlite3.connect('pi_temp.db')
|
||||
curs = conn.cursor()
|
||||
curs.execute("SELECT * FROM temperatures WHERE rDateTime BETWEEN ? AND ?", (from_date_utc.format('YYYY-MM-DD HH:mm'), to_date_utc.format('YYYY-MM-DD HH:mm')))
|
||||
temperatures = curs.fetchall()
|
@ -39,7 +39,7 @@ import sys
|
||||
import Adafruit_DHT
|
||||
|
||||
def log_values(sensor_id, temp, hum):
|
||||
conn=sqlite3.connect('/home/pi/Documents/Pi-Temp/lab_app/lab_app.db') #It is important to provide an
|
||||
conn=sqlite3.connect('/home/pi/Documents/pi-temp/pi-temp.db') #It is important to provide an
|
||||
#absolute path to the database
|
||||
#file, otherwise Cron won't be
|
||||
#able to find it!
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@ -24,7 +24,7 @@
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<form id="datetime_range" action="/lab_env_db" method="GET">
|
||||
<form id="datetime_range" action="/pi_temp_db" method="GET">
|
||||
<!-- <div class="row"> -->
|
||||
<div class="three columns">
|
||||
<label for="from">From date</label>
|
||||
@ -48,12 +48,10 @@
|
||||
<div class="row">
|
||||
<div class="eleven columns">
|
||||
<div class="one column">
|
||||
<div class="one column">
|
||||
<a href="" id="plotly" style="position:relative;top:15px">Plotly</a>
|
||||
</div>
|
||||
<a href="/lab_temp" style="position:relative;top:15px">Current</a>
|
||||
<a href="" id="plotly">Plotly</a>
|
||||
<a href="/">Live</a>
|
||||
</div>
|
||||
<form id="range_select" action = "/lab_env_db" method="GET">
|
||||
<form id="range_select" action = "/history" method="GET">
|
||||
<input type="hidden" class="timezone" name="timezone" />
|
||||
<div class="one column">
|
||||
<input type="radio" name="range_h" value="3" id="radio_3" /><label for="radio_3">3hrs</label>
|
@ -33,7 +33,7 @@
|
||||
<form id="range_select" action = "/lab_env_db" method="GET">
|
||||
<input type="hidden" class="timezone" name="timezone" />
|
||||
<div class="one column">
|
||||
<a href="/lab_env_db" style="position:relative;top:15px">Historic</a>
|
||||
<a href="/history" style="position:relative;top:15px">Historic</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
Reference in New Issue
Block a user