replace string split with shlex; show dir listing for /; naming
This commit is contained in:
10
pier.py
10
pier.py
@ -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"):
|
||||||
|
Reference in New Issue
Block a user