diff --git a/lab_app.db b/lab_app.db new file mode 100644 index 0000000..e69de29 diff --git a/lab_app/lab_app.db b/lab_app/lab_app.db deleted file mode 100755 index 2aa3813..0000000 Binary files a/lab_app/lab_app.db and /dev/null differ diff --git a/lab_app/templates/hello.html b/lab_app/templates/hello.html deleted file mode 100755 index 7bae1ee..0000000 --- a/lab_app/templates/hello.html +++ /dev/null @@ -1,22 +0,0 @@ - - - -Static page - - - - - - - - - - - -

{{ message }}

- - diff --git a/pi_temp.db b/pi_temp.db new file mode 100755 index 0000000..91b20d6 Binary files /dev/null and b/pi_temp.db differ diff --git a/lab_app/lab_app.py b/pi_temp.py similarity index 93% rename from lab_app/lab_app.py rename to pi_temp.py index 9fd25d2..cd3db19 100755 --- a/lab_app/lab_app.py +++ b/pi_temp.py @@ -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() diff --git a/lab_app/env_log.py b/pi_temp_logger.py similarity index 94% rename from lab_app/env_log.py rename to pi_temp_logger.py index f269c05..e529182 100755 --- a/lab_app/env_log.py +++ b/pi_temp_logger.py @@ -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! diff --git a/lab_app/static/css/jquery.datetimepicker.css b/static/css/jquery.datetimepicker.css similarity index 100% rename from lab_app/static/css/jquery.datetimepicker.css rename to static/css/jquery.datetimepicker.css diff --git a/lab_app/static/css/normalize.css b/static/css/normalize.css similarity index 100% rename from lab_app/static/css/normalize.css rename to static/css/normalize.css diff --git a/lab_app/static/css/skeleton.css b/static/css/skeleton.css similarity index 100% rename from lab_app/static/css/skeleton.css rename to static/css/skeleton.css diff --git a/lab_app/static/images/favicon.png b/static/images/favicon.png similarity index 100% rename from lab_app/static/images/favicon.png rename to static/images/favicon.png diff --git a/lab_app/static/javascript/jquery.datetimepicker.full.js b/static/javascript/jquery.datetimepicker.full.js similarity index 100% rename from lab_app/static/javascript/jquery.datetimepicker.full.js rename to static/javascript/jquery.datetimepicker.full.js diff --git a/lab_app/static/javascript/jquery.datetimepicker.js b/static/javascript/jquery.datetimepicker.js similarity index 100% rename from lab_app/static/javascript/jquery.datetimepicker.js rename to static/javascript/jquery.datetimepicker.js diff --git a/lab_app/templates/lab_env_db.html b/templates/history.html similarity index 96% rename from lab_app/templates/lab_env_db.html rename to templates/history.html index 684d7d5..6cb7e04 100755 --- a/lab_app/templates/lab_env_db.html +++ b/templates/history.html @@ -24,7 +24,7 @@
-
+
@@ -48,12 +48,10 @@
-
- Plotly -
- Current + Plotly + Live
- +
diff --git a/lab_app/templates/lab_temp.html b/templates/live.html similarity index 96% rename from lab_app/templates/lab_temp.html rename to templates/live.html index a4cf5fb..d9ec8ae 100755 --- a/lab_app/templates/lab_temp.html +++ b/templates/live.html @@ -33,7 +33,7 @@
diff --git a/lab_app/templates/no_sensor.html b/templates/no_sensor.html similarity index 100% rename from lab_app/templates/no_sensor.html rename to templates/no_sensor.html