machine: update request handlers to accept WebRequest objects
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
a260356d78
commit
6c8ef93f9f
|
@ -13,10 +13,11 @@ class Machine:
|
||||||
self.server.register_endpoint(
|
self.server.register_endpoint(
|
||||||
"/machine/shutdown", ['POST'], self._handle_machine_request)
|
"/machine/shutdown", ['POST'], self._handle_machine_request)
|
||||||
|
|
||||||
async def _handle_machine_request(self, path, method, args):
|
async def _handle_machine_request(self, web_request):
|
||||||
if path == "/machine/shutdown":
|
ep = web_request.get_endpoint()
|
||||||
|
if ep == "/machine/shutdown":
|
||||||
cmd = "sudo shutdown now"
|
cmd = "sudo shutdown now"
|
||||||
elif path == "/machine/reboot":
|
elif ep == "/machine/reboot":
|
||||||
cmd = "sudo shutdown -r now"
|
cmd = "sudo shutdown -r now"
|
||||||
else:
|
else:
|
||||||
raise self.server.error("Unsupported machine request")
|
raise self.server.error("Unsupported machine request")
|
||||||
|
|
Loading…
Reference in New Issue