diff --git a/aimodel/isFalling.py b/aimodel/isFalling.py index 59cf3a3..9c7b7fb 100644 --- a/aimodel/isFalling.py +++ b/aimodel/isFalling.py @@ -128,6 +128,34 @@ def json_to_xml(json_data, parent): else: parent.text = str(json_data) +#HEAVY REVERSE ENGINEERING SOLUTION TO READ DATA AND FORMAT DATA FROM XML FILES #PROUD_of_THAT +def reverst_data(): + with open('output.xml', 'r') as file: + data_xml = file.read() + + # Extract the name from the data XML + data = json.loads(ET.fromstring(data_xml).text)[0] + name = data['name'] + print(data, name) + + with open('response.xml', 'r') as file: + response_xml = file.read() + + # Replace the placeholder with the extracted name + response_tree = ET.fromstring(response_xml) + say_element = response_tree.find('.//Say') + if say_element is not None: + say_element.text = say_element.text.replace('Friend', name) + + # Save the modified XML + # with open('response.xml', 'w') as file: + # file.write(ET.tostring(response_tree).decode('utf-8')) + output_xml = ET.tostring(response_tree, encoding='utf-8').decode('utf-8') + output_xml = '\n' + output_xml + + with open('response.xml', 'w') as file: + file.write(output_xml) + @app.route('/call') diff --git a/aimodel/response.xml b/aimodel/response.xml new file mode 100644 index 0000000..1f39184 --- /dev/null +++ b/aimodel/response.xml @@ -0,0 +1,8 @@ + + + This is SafetyCall reaching out to you with an urgent notification concerning your wubeshet. It appears that they may be experiencing a panic attack and are currently on the ground. We are taking immediate action to send you their current location for prompt assistance. + + Your swift attention to this matter is crucial. Kindly ensure you act promptly and take appropriate measures to assist your friend. If you have any questions or require further information, please do not hesitate to contact us. + + Thank you for your cooperation. + \ No newline at end of file