diff --git a/app.py b/app.py index a4b995a..81f8759 100644 --- a/app.py +++ b/app.py @@ -25,11 +25,11 @@ def api_root(): } @app.route('/XML/', methods=["GET","POST"]) -def xml_transfer(): +def xml_transfer(self): try: #return the current config.xml if request.method == "GET": - return send_from_directory('XML','config.xml') + return send_from_directory(str(dir + 'XML'), 'config.xml') # set a new config.xml if request.method == "POST": @@ -40,9 +40,10 @@ def xml_transfer(): tmp_file.write(data) tmp_file.close() #check config.xml against the XSD file - if xml_reader.validate('/tmp/aped_device/config.xml','XML/config.xsd'): - shutil.move('XML/config.xml','XML/config_old.xml') - shutil.move('/tmp/aped_device/config.xml','XML/config.xml') + if xml_reader.validate('/tmp/aped_device/config.xml',str(dir + 'XML/config.xsd')): + shutil.move(str(dir + 'XML/config.xml'),str(dir + 'XML/config_old.xml')) + shutil.move('/tmp/aped_device/config.xml',str(dir + 'XML/config.xml')) + self.interface_handler = Interface_handler(self.xml_reader) else: SyntaxError('the config.xml has invalid content') return {'error': ''} @@ -54,7 +55,7 @@ def api_leds_control(device_name): try: if request.method == "POST": response = interface_handler.write(device_name,request.data.get("output")) - return {'output': response} + return {'output': str(response)} return {'state': interface_handler.read(device_name)} except Exception as e: return {'error': str(e)}