From 97e09bada81f76876294dcc420a3c8c7e8f42fef Mon Sep 17 00:00:00 2001 From: Dmitri Popov Date: Mon, 26 Mar 2018 09:38:26 +0200 Subject: [PATCH] Add redirect. Minor template fixes --- rc/rc.py | 18 +++++++++++------- rc/rc.tpl | 2 -- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/rc/rc.py b/rc/rc.py index 7bb2159..7eff520 100755 --- a/rc/rc.py +++ b/rc/rc.py @@ -13,22 +13,26 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from bottle import post, route, request, template, run +from bottle import post, route, request, redirect, template, run import os @route('/') @route('/', method='POST') def remote_control(): - #dh = os.system("df -h | grep '/dev/sda' | awk '{print $4}'") - st = os.statvfs("/home/pi") + st = os.statvfs("/home/dmpop") free = "%.2f" % float((st.f_bavail * st.f_frsize)/1.073741824e9) if (request.POST.get("cardbackup")): - os.system("sudo /home/pi/little-backup-box/scripts/card-backup.sh") + os.system("sudo /home/pi/little-backup-box/scripts/card-backup.sh") + return ('Backup started. You can close this page.') + if (request.POST.get("camerabackup")): - os.system("sudo /home/pi/little-backup-box/scripts/camera-backup.sh") + os.system("sudo /home/pi/little-backup-box/scripts/camera-backup.sh") + return ('Backup started. You can close this page.') if (request.POST.get("devicebackup")): - os.system("sudo /home/pi/little-backup-box/scripts/device-backup.sh") + os.system("sudo /home/pi/little-backup-box/scripts/device-backup.sh") + return ('Transfer started. You can close this page.') if (request.POST.get("shutdown")): - os.system("sudo shutdown -h now") + os.system("sudo shutdown -h now") + return ('Shutdown request sent. You can close this page.') return template('rc.tpl', freespace=free) run(host="0.0.0.0", port=8080, debug=True, reloader=True) diff --git a/rc/rc.tpl b/rc/rc.tpl index d67971b..664428b 100644 --- a/rc/rc.tpl +++ b/rc/rc.tpl @@ -1,6 +1,5 @@ -