Revision 5a52f49b
Added by dsorber about 13 years ago
| 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')"
|
||
It would help if I spelled the acronym right...