Skip to content
Snippets Groups Projects
Commit 53166752 authored by jkerdreu's avatar jkerdreu
Browse files

Nothing

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/fork@1651 b32b6428-25c9-4566-ad07-03861ab6144f
parent 30a28420
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ from xaal.lib import tools,Engine,Device
from xaal.monitor import Monitor
import platform
from bottle import default_app,debug,get,abort, response
from bottle import default_app,debug,get,response
import json
......@@ -17,7 +17,7 @@ from geventwebsocket.handler import WebSocketHandler
PACKAGE_NAME = "xaal.rest"
logger = tools.get_logger(PACKAGE_NAME,'DEBUG')
# we use this global variable to share data with
# we use this global variable to share data with greenlet
monitor = None
def setup_xaal():
......@@ -47,6 +47,7 @@ def xaal_loop(engine):
@get('/devices/')
def list_devices():
""" Return the list of devices in JSON"""
l = []
for dev in monitor.devices:
h = {'address':dev.address,'devtype':dev.devtype}
......@@ -54,8 +55,10 @@ def list_devices():
response.headers['Content-Type'] = 'application/json'
return json.dumps(l,indent=4)
@get('/devices/<addr>')
def get_device(addr):
""" Return the full description of a device """
dev=monitor.devices.get_with_addr(addr)
response.headers['Content-Type'] = 'application/json'
......@@ -67,8 +70,8 @@ def get_device(addr):
res = {'error':{'code':404,'message':'Unknow device'}}
response.status=404
return json.dumps(res,indent=4)
def run():
setup_xaal()
app = default_app()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment