Last active
March 2, 2023 08:54
-
-
Save hazho/951a7c1afce50785798077e4c332b76e to your computer and use it in GitHub Desktop.
questions to clarify the requirements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# at Line Number 42, replace by this code until Line: 77 that contains (# Create a URL route in our application for "/") | |
# Create a URL route in our application for "/fill_json" | |
@app.route('/fill_json', methods=['GET', 'POST']) | |
def fill_available_data_types(): | |
if request.method == 'POST': | |
json_data = request.json | |
print(json_data) | |
cleaned_data_types = [] | |
our_accepted_list_of_data_type = ["ECG", "Floorplan", "Doorcode", "Rescue card", "DAR", "Video", "Audio"] | |
available_data = json_data["available_data_types"] | |
if type(available_data) == list: | |
print("it is list") | |
for data_type in available_data: | |
if data_type in our_accepted_list_of_data_type: | |
cleaned_data_types.append(data_type) | |
else: | |
return {"message": f"the {data_type} is not among the acceptable data types, please reconfirm you entered the data types that are corresponding to any of ({our_accepted_list_of_data_type})."} | |
print(cleaned_data_types) | |
with open("datatypes.json", "w") as json_file: json_file.write(str(cleaned_data_types)) | |
return {"message": "available_data_types had been posted", "available_data_types are": cleaned_data_types} | |
elif type(available_data) == dict: | |
print("it is Dict") | |
for data_type in available_data.keys(): | |
if data_type in our_accepted_list_of_data_type: | |
cleaned_data_types.append(data_type) | |
else: | |
return {"message": f"the {data_type} is not among the acceptable data types, please reconfirm you entered the data types that are corresponding to any of ({our_accepted_list_of_data_type})."} | |
print(cleaned_data_types) | |
with open("datatypes.json", "w") as json_file: json_file.write(str(cleaned_data_types)) | |
return {"message": "available_data_types had been posted", "available_data_types are": cleaned_data_types} | |
elif type(available_data) == str: | |
return {"message": type(available_data)} | |
else: | |
return {"message": f"the information you sent are not in a form that accepted {type(available_data)} is not of (string, list/array and/or dictionary/object) please reconfirm you entered the data correctly."} | |
if request.method == 'GET': | |
return {"message": "this is get only"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Provided_Information": | |
{ | |
"ecg": true, | |
"floorplan": true, | |
"video": true, | |
"dar": true, | |
"doorcode": false, | |
"audio_stream": false, | |
"recue_sheet": true, | |
"crypto_data": false | |
} | |
} |
keep-alive connection should start right at alerting event (ICT systems)
virtual accident registry, should be first step after we build each service as an ecosystem Minimum Viable Product(MVP) of ISAN
dynamic data types (to be scalable based on human life development)
available data to be set dynamically, this will require IoT edge devices that involved.
fetch('http://localhost:5555/fill_json', {
headers:{"Content-Type":"application/json"},
method: 'POST', body: '{"available_datat_types":{"Rescue card":true,"Doorcode":true}}'
})
.then((response) => response.text())
.then((result) => {
console.log('Success:', result);
})
.catch((error) => {
console.error('Error:', error);
});
keep in mind that Data Types Keys should be exactly as your new code at (our_accepted_list_of_data_type)
in file templates/home.html
{% for datatype in avail_data %}
<input type="checkbox" id="{{datatype}}" name="{{datatype}}">
<label for="{{datatype}}">{{datatype}}</label>
{% endfor %}
<textarea name="data_types" id="" cols="100" >
</textarea>
<script>
let form=document.querySelector('form');
fetch('http://localhost:5555/fill_json', {
headers:{"Content-Type":"application/json"},
method: 'POST', body: `${ form.data_types.value }`
})
.then((response) => response.text())
.then((result) => {
console.log('Success:', result);
})
.catch((error) => {
console.error('Error:', error);
});
</script>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
case1:
if the requirement is to create a tool to dynamically add or remove number of data types, the solution is to creatre a DB table to store these configs, and can be manipulated by human user... this can be achieved by installing sqlalchemy and create ORM models that interact with the DB table and the Jinja form template.
Pros:
Cons:
case2:
if the requirement is to let the human user be able to edit the availability of an alerting data types at the alerting time, in this case the solution is to have a JSON file in the AS service code base that can be edited by permitted (registered) IoT edge devices...this could be achieved by an API endpoint I create to receive changes needed by registered IoT devices on the ecosystem.. this endpoint will open and modify the JSON file and closed.
Pros:
Cons: