summaryrefslogtreecommitdiffstats
path: root/ogcp/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'ogcp/views.py')
-rw-r--r--ogcp/views.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index 9d44b55..92e91b2 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1,4 +1,5 @@
from flask import g, render_template, url_for, request, jsonify, make_response
+from ogcp.forms.action_forms import WOLForm
from ogcp.og_server import OGServer
from flask_babel import _
from ogcp import app
@@ -49,6 +50,20 @@ def action_poweroff():
g.server.post('/poweroff', payload)
return make_response("200 OK", 200)
+@app.route('/action/wol', methods=['GET', 'POST'])
+def action_wol():
+ form = WOLForm(request.form)
+ if request.method == 'POST' and form.validate():
+ wol_type = form.wol_type.data
+ ips = parse_ips(request.form.to_dict())
+ payload = {'type': wol_type, 'clients': list(ips)}
+ g.server.post('/wol', payload)
+ return make_response("200 OK", 200)
+ else:
+ ips = parse_ips(request.args.to_dict())
+ form.ips.data = " ".join(ips)
+ return render_template('actions/wol.html', form=form)
+
@app.route('/action/reboot', methods=['POST'])
def action_reboot():
ips = parse_ips(request.form.to_dict())