From 8fd394824e66c186b0692afc0da0db676df6f11c Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Wed, 11 May 2022 10:12:43 +0200 Subject: [PATCH] replace string split with shlex; show dir listing for /; naming --- pier.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pier.py b/pier.py index 4249aaa..215771d 100755 --- a/pier.py +++ b/pier.py @@ -26,17 +26,23 @@ from io import StringIO import os import sys +import shlex import http.server import socketserver -HTML_SPACE = "%20" +URL_SPACE = "%20" class ScriptServer(http.server.SimpleHTTPRequestHandler): def do_GET(self): - args = self.path.lstrip("/").split(HTML_SPACE) + args = self.path.lstrip("/").replace(URL_SPACE, " ") + args = shlex.split(args) + + if not args: + super().do_GET() + scr = args[0] if not scr.endswith(".py"):