diff options
Diffstat (limited to 'src/server.py')
-rwxr-xr-x | src/server.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/server.py b/src/server.py index 9ffe6f1..a0fa7c4 100755 --- a/src/server.py +++ b/src/server.py @@ -30,9 +30,12 @@ def default_html_dir(): class RequestHandler(http.server.SimpleHTTPRequestHandler): + ARGS = None + def do_GET(self): try: request = Request.from_http_path(self.path) + request.disable_power = RequestHandler.ARGS.disable_power except ValueError: return super().do_GET() try: @@ -60,6 +63,8 @@ def parse_args(args=None): parser.add_argument('-p', '--port', metavar='PORT', type=int, default=DEFAULT_PORT, help='set port number') + parser.add_argument('-n', '--disable-power', action='store_true', + help='disable reboot/poweroff requests') parser.add_argument('-d', '--dir', metavar='DIR', default=default_html_dir(), help='HTML directory path') @@ -68,6 +73,7 @@ def parse_args(args=None): def main(args=None): args = parse_args(args) + RequestHandler.ARGS = args # It's a failsafe; the script is not allowed to serve a random current # working directory. |