Start work on environment data
This commit is contained in:
parent
5be1042cd7
commit
4e43c799f7
|
@ -198,6 +198,8 @@ def getCyberware():
|
|||
|
||||
@app.route('/api/cyberware/get')
|
||||
def getCyberwareSpecific():
|
||||
json = request.get_json()
|
||||
|
||||
try:
|
||||
desiredId = json['uuid']
|
||||
i = 0
|
||||
|
@ -217,6 +219,57 @@ def resetCyberwareMalfunction():
|
|||
|
||||
return 'Not Implemented', 501
|
||||
|
||||
# Environment data
|
||||
environmentTemperature = -1
|
||||
environmentHumidity = -1
|
||||
|
||||
@app.route('/api/environment')
|
||||
def getEnvironment():
|
||||
returnArr = [ { 'temperature': environmentTemperature, 'humidity': environmentHumidity } ]
|
||||
return jsonify(returnArr), 200
|
||||
|
||||
# Environment//Temperature
|
||||
@app.route('/api/environment/temperature')
|
||||
def getEnvironmentTemperature():
|
||||
returnArr = [ { 'temperature': environmentTemperature } ]
|
||||
return jsonify(returnArr), 200
|
||||
|
||||
@app.route('/api/environment/temperature', methods=['POST'])
|
||||
def setEnvironmentTemperature():
|
||||
global environmentTemperature
|
||||
json = request.get_json()
|
||||
|
||||
try:
|
||||
tempTemperature = json['temperature']
|
||||
|
||||
environmentTemperature = tempTemperature
|
||||
except:
|
||||
return 'Incorrect usage.\nUsage: { temperature: INT, uuid: STRING }\n', 400
|
||||
return '', 204
|
||||
|
||||
# Environment//Humidity
|
||||
@app.route('/api/environment/humidity')
|
||||
def getEnvironmentHumidity():
|
||||
returnArr = [ { 'humidity': environmentHumidity } ]
|
||||
return jsonify(returnArr), 200
|
||||
|
||||
@app.route('/api/environment/humidity', methods=['POST'])
|
||||
def setEnvironmentHumidity():
|
||||
global environmentHumidity
|
||||
json = request.get_json()
|
||||
|
||||
try:
|
||||
tempHumidity = json['humidity']
|
||||
|
||||
environmentHumidity = tempHumidity
|
||||
except:
|
||||
return 'Incorrect usage.\nUsage: { humidity: INT, uuid: STRING }\n', 400
|
||||
return '', 204
|
||||
|
||||
# Authentication method
|
||||
# This authorizes the given UUID to determine whether the request is
|
||||
# allowed to set the requested endpoint.
|
||||
# This is ONLY used for PUSH requests currently.
|
||||
def authenticate(uuid, endpoint):
|
||||
for c in cyberware: # UUID Match
|
||||
if c['uuid'] == uuid:
|
||||
|
|
Loading…
Reference in a new issue