diff options
author | yvesf <yvesf-git@xapek.org> | 2011-06-25 17:14:05 +0200 |
---|---|---|
committer | yvesf <yvesf-git@xapek.org> | 2011-06-25 17:14:05 +0200 |
commit | a85541d9f7622813ec98bf042164414edc1fb366 (patch) | |
tree | 8041b06bb1681642777244d1955356bd63af25b7 /ebus/web/controller.py | |
parent | c15f4a600ddc3155b761230b84d78458e08bdc40 (diff) | |
download | ebus-alt-a85541d9f7622813ec98bf042164414edc1fb366.tar.gz ebus-alt-a85541d9f7622813ec98bf042164414edc1fb366.zip |
web -> bottle
Diffstat (limited to 'ebus/web/controller.py')
-rw-r--r-- | ebus/web/controller.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/ebus/web/controller.py b/ebus/web/controller.py index 683bb6c..99d7053 100644 --- a/ebus/web/controller.py +++ b/ebus/web/controller.py @@ -6,7 +6,7 @@ from werkzeug.contrib.cache import SimpleCache from simplejson import dumps as dump_json from sqlalchemy.orm import sessionmaker -from ebus import model +from ebus.web import model Session = sessionmaker() @@ -35,13 +35,14 @@ def index(req): filename=os.path.join(os.path.dirname(__file__), "static", "index.html") return open(filename,"r").read() -@itty.get('/json/(?P<sensor>[^/]+)') -@itty.get('/json/(?P<sensor>[^/]+)/from_date/(?P<from_date>[^/]+)') -@itty.get('/json/(?P<sensor>[^/]+)/from_date/(?P<from_date>[^/]+)/till_date/(?P<till_date>[^/]+)') +#@itty.get('/json/(?P<sensor>[^/]+)') +#@itty.get('/json/(?P<sensor>[^/]+)/from_date/(?P<from_date>[^/]+)') +#@itty.get('/json/(?P<sensor>[^/]+)/from_date/(?P<from_date>[^/]+)/till_date/(?P<till_date>[^/]+)') @CacheDecorator(key=lambda args,kwargs: tuple(kwargs.keys()) + tuple(kwargs.values()), timeout=20) def json(req,sensor=None,from_date=None,till_date=None): print "sensor=%s from_date=%s till_date=%s" % (sensor,from_date,till_date) + """ values = Session().query(model.Value).join(model.Sensor) if sensor: @@ -56,9 +57,17 @@ def json(req,sensor=None,from_date=None,till_date=None): response = {"sensor":sensor, "from_date":from_date, "till_date":till_date, "values":values.all()} return itty.Response(dump_json(response), content_type="application/json") + """ + return itty.Response("") + +@itty.get('/json/list') +def list(req): + sensors = Session().query(model.Sensor) + return str(sensors.all()) @itty.get("/static/(?P<filename>.+)") def static(request,filename): + return "" file = itty.static_file(filename, root=os.path.join(os.path.dirname(__file__), 'static')) return itty.Response(file, content_type=itty.content_type(file)) |