replace string split with shlex; show dir listing for /; naming

This commit is contained in:
2022-05-11 10:12:43 +02:00
parent 7cd9383e9c
commit 8fd394824e

10
pier.py
View File

@ -26,17 +26,23 @@ from io import StringIO
import os import os
import sys import sys
import shlex
import http.server import http.server
import socketserver import socketserver
HTML_SPACE = "%20" URL_SPACE = "%20"
class ScriptServer(http.server.SimpleHTTPRequestHandler): class ScriptServer(http.server.SimpleHTTPRequestHandler):
def do_GET(self): 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] scr = args[0]
if not scr.endswith(".py"): if not scr.endswith(".py"):