powerbar-api
This commit is contained in:
parent
ab33cec8a0
commit
852d08a91d
1 changed files with 13 additions and 0 deletions
13
app/views.py
13
app/views.py
|
@ -77,3 +77,16 @@ def powerbar_state(powerbar, outlet):
|
|||
|
||||
state = powerbars[powerbar]['outlets'][outlet].get('state', 'unknown')
|
||||
return jsonify({'state': state})
|
||||
|
||||
|
||||
@routes.route('/powerbars')
|
||||
def powerbars_list():
|
||||
return jsonify(powerbars)
|
||||
|
||||
@routes.route('/powerbars/<string:powerbar>')
|
||||
def powerbar_outlets(powerbar):
|
||||
if not vaild_power_bar(powerbar):
|
||||
print("Invalid powerbar")
|
||||
return jsonify({'error': 'Invalid powerbar'}), 400
|
||||
|
||||
return jsonify(powerbars[powerbar]['outlets'])
|
||||
|
|
Loading…
Reference in a new issue