diff --git a/src/nightserver.py b/src/nightserver.py index 9b0f115..2cfeb2f 100644 --- a/src/nightserver.py +++ b/src/nightserver.py @@ -1,6 +1,63 @@ -from flask import Flask, render_template +from flask import Flask, render_template, jsonify, request app = Flask(__name__) +# Vitals +vitalsHeartrate = 0 +vitalsOxygen = 0 +vitalsBodytemp = 0.0 + +@app.route('/api/vitals/heartrate') +def getVitalsHeartrate(): + returnArr = [ { 'heartrate': vitalsHeartrate } ] + return jsonify(returnArr) + +@app.route('/api/vitals/heartrate', methods=['POST']) +def setVitalsHeartrate(): + global vitalsHeartrate + json = request.get_json() + try: + vitalsHeartrate = json['heartrate'] + except: + return 'Incorrect usage.\nUsage: { heartrate: INT }\n', 400 + return 'Information set successfully', 204 + +@app.route('/api/vitals/oxygen') +def getVitalsOxygen(): + returnArr = [ { 'oxygen': vitalsOxygen } ] + return jsonify(returnArr) + +@app.route('/api/vitals/oxygen', methods=['POST']) +def setVitalsOxygen(): + global vitalsOxygen + json = request.get_json() + try: + vitalsOxygen = json['oxygen'] + except: + return 'Incorrect usage.\nUsage: { oxygen: INT }\n', 400 + return 'Information set successfully', 204 + +@app.route('/api/vitals/bodytemp') +def getVitalsBodytemp(): + returnArr = [ { 'bodytemp': vitalsBodytemp } ] + return jsonify(returnArr) + +@app.route('/api/vitals/bodytemp', methods=['POST']) +def setVitalsBodytemp(): + global vitalsBodytemp + json = request.get_json() + try: + vitalsBodytemp = json['bodytemp'] + except: + return 'Incorrect usage.\nUsage: { bodytemp: FLOAT }\n', 400 + return 'Information set successfully', 204 + +@app.route('/api/vitals') +def getVitals(): + returnArr = [ { 'heartrate': vitalsHeartrate, 'oxygen': vitalsOxygen, 'bodytemp': vitalsBodytemp } ] + return jsonify(returnArr) + + + @app.route('/') def uiindex(): return render_template('index.html') diff --git a/src/templates/index.html b/src/templates/index.html index 96c092e..d778ae7 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -28,30 +28,48 @@ padding: 2px; display: flex; flex-wrap: wrap; - border: 1px solid #0FF; /* TODO: Remove this later */ + /*border: 1px solid #0FF;*/ /* TODO: Remove this later */ } /* Below are all Vitals styling */ #vitals { + display: flex; + flex: none; + line-height: 0; + flex-direction: column; + text-align: left; margin-left: 2px; /*flex-grow: 1;*/ width: 30%; - border: 1px solid #F00; /* TODO: Remove this later. */ + /*border: 1px solid #F00;*/ /* TODO: Remove this later. */ + } + + #heartrate { + + } + + #oxygen { + + } + + #bodyTemperature { + } /* Below are all Top Message styling */ #topMessage { + align-self: center; flex-grow: 2; margin-left: 2px; margin-right: 2px; - border: 1px solid #0F0; /* TODO: Remove this later */ + border: 1px solid #F00; /* TODO: Remove this later */ } /* Below are all Map styling */ #map { margin-right: 2px; width: 30%; - border: 1px solid #00F; /* TODO: Remove this later */ + /*border: 1px solid #00F;*/ /* TODO: Remove this later */ } #mapElements { @@ -73,7 +91,7 @@ } #projectName { - + align-self: flex-end; } #compass { @@ -150,10 +168,18 @@
Vitals
+Heartrate: 0 BPM
+Oxygen: 0% O2
+Body Temp: 0°C
+Top message
+Top message - Notifications, warnings, and malfunctions and such
K.A.T.I.E.
+0°C