| 588 | handler.wfile.write(json.dumps({"status": "error", "message": str(e)}).encode('utf-8')) |
| 589 | |
| 590 | def reboot_system(self, handler): |
| 591 | try: |
| 592 | command = "sudo reboot" |
| 593 | subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) |
| 594 | handler.send_response(200) |
| 595 | handler.send_header("Content-type", "application/json") |
| 596 | handler.end_headers() |
| 597 | handler.wfile.write(json.dumps({"status": "success", "message": "System is rebooting"}).encode('utf-8')) |
| 598 | except subprocess.CalledProcessError as e: |
| 599 | handler.send_response(500) |
| 600 | handler.send_header("Content-type", "application/json") |
| 601 | handler.end_headers() |
| 602 | handler.wfile.write(json.dumps({"status": "error", "message": str(e)}).encode('utf-8')) |
| 603 | |
| 604 | def shutdown_system(self, handler): |
| 605 | try: |