Project

General

Profile

« Previous | Next » 

Revision 5a52f49b

Added by dsorber about 13 years ago

It would help if I spelled the acronym right...

View differences:

525.743/code/web/README
1. Install apache and mod_wsgi.
2. Add this line to your apache config file
WSGIScriptAlias /bcfs /path/to/web/folder/app.wsgi
WSGIScriptAlias /bfcs /path/to/web/folder/app.wsgi
3. Restart apache and you should be able to see BCFS web display at "/bcfs".
3. Restart apache and you should be able to see BCFS web display at "/bfcs".
525.743/code/web/app.wsgi
import os
import sqlite3
from genshi.template import TemplateLoader
from genshi.template.base import Context
DB_PATH = '/home/dsorber/bcfs/beer_temps.db'
BASE_PATH = '/home/dsorber/bfcs'
DB_PATH = os.path.join(BASE_PATH, 'beer_temps.db')
TEMPLATE_PATH = os.path.join(BASE_PATH, 'templates')
# It accepts two arguments:
# environ points to a dictionary containing CGI like environment variables
......
def application(environ, start_response):
loader = TemplateLoader('/home/dsorber/bcfs/templates',
auto_reload=True)
# Testing purposes only -- REMOVE BEFORE SHIPPING
response_body = 'The environ dict: %s' % environ['PATH_INFO']
loader = TemplateLoader(TEMPLATE_PATH, auto_reload=True)
if not environ['PATH_INFO']:
# Load the index template
......
# grab the results, then close the DB connection.
db_conn = sqlite3.connect(DB_PATH)
db = db_conn.cursor()
db.execute("select strftime('%m/%d/%Y %H:%M:%S', ts, 'unixepoch'), "
db.execute("select strftime('%H:%M:%S', ts, 'unixepoch'), "
" temp1, temp2, temp3, temp4, relay_status "
"from temp_data "
"where date(ts, 'unixepoch') is date('2013-04-22')"
525.743/code/web/templates/day.html
<h1>${title}</h1>
<table>
<tr>
<th>Datetime</th>
<th>Time</th>
<th class="sensor1">Sensor 1</th>
<th class="sensor2">Sensor 2</th>
<th class="sensor3">Sensor 3</th>
......
<th class="max">Relay Status</th>
</tr>
<tr py:for="ctr, row in enumerate(results)" class="${ctr % 2 and 'odd' or 'even'}">
<td><a href="bcfs/day/${row[0][3:5] + row[0][0:2] + row[0][6:10]}">${row[0]}</a></td>
<td>${row[0]}</td>
<td class="center">${row[1]}</td>
<td class="center">${row[2]}</td>
<td class="center">${row[3]}</td>
525.743/code/web/templates/index.html
<th class="min">Min</th>
</tr>
<tr py:for="ctr, row in enumerate(results)" class="${ctr % 2 and 'odd' or 'even'}">
<td><a href="bcfs/day/${row[0][3:5] + row[0][0:2] + row[0][6:10]}">${row[0]}</a></td>
<td><a href="bfcs/day/${row[0][3:5] + row[0][0:2] + row[0][6:10]}">${row[0]}</a></td>
<td class="center">${row[1]}</td>
<td class="center">${round(float(row[2]), 3)}</td>
<td class="center">${row[3]}</td>

Also available in: Unified diff