machine: update request handlers to accept WebRequest objects

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2020-11-09 07:01:57 -05:00
parent a260356d78
commit 6c8ef93f9f
1 changed files with 4 additions and 3 deletions

View File

@ -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")