diff --git a/pwnagotchi/ui/web/handler.py b/pwnagotchi/ui/web/handler.py index 788a3d1..f855253 100644 --- a/pwnagotchi/ui/web/handler.py +++ b/pwnagotchi/ui/web/handler.py @@ -34,6 +34,7 @@ class Handler: self._app.add_url_rule('/ui', 'ui', self.with_auth(self.ui)) self._app.add_url_rule('/shutdown', 'shutdown', self.with_auth(self.shutdown), methods=['POST']) + self._app.add_url_rule('/reboot', 'reboot', self.with_auth(self.reboot), methods=['POST']) self._app.add_url_rule('/restart', 'restart', self.with_auth(self.restart), methods=['POST']) # inbox @@ -201,6 +202,14 @@ class Handler: finally: _thread.start_new_thread(pwnagotchi.shutdown, ()) + # serve a message and reboot the unit + def reboot(self): + try: + return render_template('status.html', title=pwnagotchi.name(), go_back_after=60, + message='Rebooting ...') + finally: + _thread.start_new_thread(pwnagotchi.reboot, ()) + # serve a message and restart the unit in the other mode def restart(self): mode = request.form['mode'] diff --git a/pwnagotchi/ui/web/templates/index.html b/pwnagotchi/ui/web/templates/index.html index 8463cd2..475a97a 100644 --- a/pwnagotchi/ui/web/templates/index.html +++ b/pwnagotchi/ui/web/templates/index.html @@ -26,6 +26,13 @@ window.onload = function() { <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/> </form> </li> + <li> + <form class="action" method="post" action="/reboot" + onsubmit="return confirm('this will reboot the unit, continue?');"> + <input type="submit" class="button ui-btn ui-corner-all" value="Reboot"/> + <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/> + </form> + </li> <li> <form class="action" method="post" action="/restart" onsubmit="return confirm('This will restart the service in {{ other_mode }} mode, continue?');">