Commit 45464383 authored by Kristian Tan's avatar Kristian Tan

Added remove device functionality

parent 43118966
......@@ -183,6 +183,20 @@ def handle_new_device():
return render_template('main.html', **template_data)
@app.route('/delete/<delete_pin')
def delete_pin(delete_pin):
for key in pins:
if key == delete_pin:
pins.pop(delete_pin)
template_data = {
'pins': pins,
'daily_total': daily_total,
'todays_cost': todays_cost,
'cost_per_kWh': os.environ['cost_per_kWh'],
}
return render_template('main.html', **template_data)
@app.route("/update_info/kWh")
def change_kWh():
template_data = {
......@@ -195,6 +209,5 @@ def change_kWh():
return render_template('main.html', **template_data)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8090)
......@@ -21,6 +21,7 @@
(<a href="/toggle/{{pin}}">turn off</a>)
{% else %}
(<a href="/toggle/{{pin}}">turn on</a>)
(<a href="/remove/{{pin}}">remove</a>)
</p>
{% endif %}
{% endif %}
......
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