diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-04-11 11:36:31 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-04-11 11:36:31 +0200 |
commit | 1a3a8f1ec191d3811730fd149521abcb2205a018 (patch) | |
tree | 7905c1e2ebb681dd2302f1eb1af34d2fe8237f73 /src/server.py | |
parent | app.py: print HTTP status when CGIing (diff) | |
download | linux-status-1a3a8f1ec191d3811730fd149521abcb2205a018.tar.gz linux-status-1a3a8f1ec191d3811730fd149521abcb2205a018.zip |
support disallowing power requestsv2.1
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. |