summaryrefslogtreecommitdiff
path: root/ebus/webapp/__init__.py
diff options
context:
space:
mode:
authoryvesf <yvesf-git@xapek.org>2011-07-24 11:05:42 +0200
committeryvesf <yvesf-git@xapek.org>2011-07-24 11:05:42 +0200
commit75017423563a18986aa096566d8a2969c32c3588 (patch)
treebd86ab746dd06f71ebd1b723e3bec754805e8736 /ebus/webapp/__init__.py
parenta0382ecfbef32b47b7438170feaa7b81d7bc22db (diff)
downloadebus-alt-75017423563a18986aa096566d8a2969c32c3588.tar.gz
ebus-alt-75017423563a18986aa096566d8a2969c32c3588.zip
clean up file structure, use bottle soup plugin
Diffstat (limited to 'ebus/webapp/__init__.py')
-rw-r--r--ebus/webapp/__init__.py28
1 files changed, 7 insertions, 21 deletions
diff --git a/ebus/webapp/__init__.py b/ebus/webapp/__init__.py
index 2a92b57..9870e95 100644
--- a/ebus/webapp/__init__.py
+++ b/ebus/webapp/__init__.py
@@ -1,39 +1,25 @@
# -*- coding: utf-8 -*-
# vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=python
-
-import bottle
-import sqlalchemy
-from sqlalchemy import create_engine, select
-from sqlalchemy.orm import sessionmaker
-from sqlalchemy.sql import text
-
-from sqlalchemy.ext.sqlsoup import SqlSoup
-from sqlalchemy import or_, and_, desc
-
-from ebus.sql import model
import os
import json
import datetime
import time
-app = bottle.Bottle("ebus")
-bottle.debug()
-engine = create_engine("postgresql:///ebus", echo=True)
-Session = sessionmaker()
-Session.configure(bind=engine)
+import bottle
+from sqlalchemy import text
-soup = SqlSoup(engine)
+app = bottle.Bottle("ebus")
@app.route('/')
def index_file():
return static_files("index.html")
-@app.route('/static/:filename')
+@app.route('/static/:filename#.+#')
def static_files(filename):
return bottle.static_file(filename, root=os.path.join(os.path.dirname(__file__),"static"))
@app.route('/sensor/:name')
-def sensor_data(name):
+def sensor_data(soup,name):
try:
# get sensor_id for name
sensor_id = soup.sensor.filter(soup.sensor.name == name).one().id
@@ -52,7 +38,7 @@ def sensor_data(name):
return {'sensor':name,'data':None, 'error':str(e)}
@app.route('/sensor/:name/:startdate/:enddate')
-def sensor_data_fromto(name,startdate,enddate):
+def sensor_data_fromto(soup,name,startdate,enddate):
try:
interval = float(enddate) - float(startdate)
if interval <= 0: raise Exception("Invalid interval")
@@ -94,7 +80,7 @@ def maketime(datetime):
return (time.mktime(datetime.timetuple())+time.altzone*-1)*1000
@app.route('/sensor_cached/:name/:timestamp_from')
-def sensor_data_cached_fromto(name, timestamp_from):
+def sensor_data_cached_fromto(soup, name, timestamp_from):
try:
timestamp_from = datetime.datetime.fromtimestamp(float(timestamp_from))