Commit 94b8b3ac authored by Yomal-Dulanjana's avatar Yomal-Dulanjana

Arduino Data send test-1 Pass

parent 5bafd706
...@@ -26,6 +26,37 @@ thread1.start() ...@@ -26,6 +26,37 @@ thread1.start()
print("test") print("test")
@app.route('/record', methods=['POST'])
def record():
data = request.get_json()
temperature = data['temperature']
# Heart Rate
bpm = data['bpm']
spo2 = data['spo2']
# temperature = random.uniform(29, 38)
# temperature = round(temperature, 2)
# bpm = random.randint(60, 100)
# spo2 = random.randint(80, 110)
print(temperature, bpm, spo2)
health_collection = db['health']
health_document = {
"HeartRate": bpm,
"BloodOxygenLevel": spo2,
"BodyTemperature": temperature,
"created_at": datetime.now(),
"updated_at": datetime.now()
}
health_collection.insert_one(health_document)
return Response(
response=json.dumps({
"status": "success",
"records": "Recieved"
}),
status=200,
mimetype="application/json"
)
if __name__ == "__main__": if __name__ == "__main__":
app.run( app.run(
debug=True, debug=True,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment