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

Add request parameter => body{}

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@2115 b32b6428-25c9-4566-ad07-03861ab6144f
parent dfe40945
Branches
No related tags found
No related merge requests found
from gevent import monkey; monkey.patch_all()
from xaal.lib import tools,Engine,Device
from xaal.lib import tools,Engine,Device,helpers
from xaal.monitor import Monitor
from bottle import default_app,debug,get,response,redirect,static_file
from bottle import default_app,debug,get,request,response,redirect,static_file
import json
import os
......@@ -107,10 +107,14 @@ def get_device(addr):
@get('/devices/<addr>/<action>')
def send_request(addr,action):
""" quick & dirty way to send request to device, no body accepted"""
#import pdb;pdb.set_trace()
body = {}
for k in request.query.keys():
body.update({k:request.query[k]})
dev=monitor.devices.get_with_addr(addr)
response.headers['Content-Type'] = 'application/json'
if dev:
monitor.engine.send_request(monitor.dev,[addr,],action)
monitor.engine.send_request(monitor.dev,[addr,],action,body)
res = {'address':dev.address}
else:
res = {'error':{'code':404,'message':'Unknow device'}}
......@@ -121,6 +125,8 @@ def send_request(addr,action):
def run():
""" start the xAAL stack & launch the HTTP stuff"""
helpers.set_console_title(PACKAGE_NAME)
helpers.setup_console_logger(level=logging.INFO)
setup_xaal()
app = default_app()
debug(True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment