Update Python simple server script to allow subdomains

This commit is contained in:
Erik Ziegler 2017-10-19 13:20:06 +02:00
parent 8957b4ed8b
commit 1d9b7d855d

View File

@ -3,9 +3,23 @@ import urlparse, os
PORT = 3000
## Note: If you set this parameter, you can try to serve files
# at a subdirectory. You should use
# -u http://localhost:3000/subdirectory
# when building the application, which will set this as your
# ROOT_URL.
#URL_PATH="/subdirectory"
URL_PATH=""
class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
# Strip the subdirectory from the PATH
# e.g. localhost:3000/subdirectory/packages/ohif_polyfill/svg4everybody.min.js
# is interpreted by this script as localhost:3000/packages/ohif_polyfill/svg4everybody.min.js
# so the file is found properly.
self.path = self.path.replace(URL_PATH, "")
# Parse query data to find out what was requested
parsedParams = urlparse.urlparse(self.path)