HarrisonA
Posts: 25
Joined: Tue Mar 19, 2019 5:48 pm

Shutdown/Reboot from a html webpage (flask)

Wed Apr 17, 2019 2:49 pm

Hello,

I am currently trying to add buttons/links on my html webpage (using flask) to issue reboot and shutdown commands to my raspberry pi. I have found ways to do this using php but I want to have a solution I can add to my already built webpage. Any suggestions?

Thanks!

Andyroo
Posts: 3351
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Shutdown/Reboot from a html webpage (flask)

Wed Apr 17, 2019 5:23 pm

Given that you are running Python to drive Flask why not just trap a button press and then use

Code: Select all

import os
os.system(‘sudo shutdown now’)
Note as I am on the iPad, the quotes are wrong and should just be single quotes :oops:
Need Pi spray - these things are breeding in my house...

HarrisonA
Posts: 25
Joined: Tue Mar 19, 2019 5:48 pm

Re: Shutdown/Reboot from a html webpage (flask)

Wed Apr 17, 2019 7:16 pm

Awesome I'll try that out!

Andyroo
Posts: 3351
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Shutdown/Reboot from a html webpage (flask)

Wed Apr 17, 2019 7:19 pm

Remember to save before running :lol:
Need Pi spray - these things are breeding in my house...

Return to “Python”