Add redirect. Minor template fixes

This commit is contained in:
Dmitri Popov
2018-03-26 09:38:26 +02:00
parent cb7babdb68
commit 97e09bada8
2 changed files with 11 additions and 9 deletions

View File

@@ -13,22 +13,26 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from bottle import post, route, request, template, run from bottle import post, route, request, redirect, template, run
import os import os
@route('/') @route('/')
@route('/', method='POST') @route('/', method='POST')
def remote_control(): def remote_control():
#dh = os.system("df -h | grep '/dev/sda' | awk '{print $4}'") st = os.statvfs("/home/dmpop")
st = os.statvfs("/home/pi")
free = "%.2f" % float((st.f_bavail * st.f_frsize)/1.073741824e9) free = "%.2f" % float((st.f_bavail * st.f_frsize)/1.073741824e9)
if (request.POST.get("cardbackup")): 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")): 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")): 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")): 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) return template('rc.tpl', freespace=free)
run(host="0.0.0.0", port=8080, debug=True, reloader=True) run(host="0.0.0.0", port=8080, debug=True, reloader=True)

View File

@@ -1,6 +1,5 @@
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="static/styles.css">
<style> <style>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
body { body {
@@ -49,4 +48,3 @@
<p><input id="btn" class="red" name="shutdown" value="Shut down" type="submit" /></p> <p><input id="btn" class="red" name="shutdown" value="Shut down" type="submit" /></p>
<p class="left">Shut down the Little Backup Box</p> <p class="left">Shut down the Little Backup Box</p>
</div> </div>
</form>