diff --git a/simpleFileServer.py b/simpleFileServer.py index ef5cc9d..8c6b963 100644 --- a/simpleFileServer.py +++ b/simpleFileServer.py @@ -1,4 +1,5 @@ import http.server +import os import socketserver from urllib.parse import urlparse from urllib.parse import parse_qs @@ -15,13 +16,19 @@ class serveRA(http.server.SimpleHTTPRequestHandler): query = parse_qs(urlparse(self.path).query) if 'grpName' in query: grpName = query['grpName'][0] + grpfile = "./" + if os.path.exists(f"./wlgrps/{grpName}.cfg"): + grpfile += f"wlgrps/{grpName}.cfg" + elif os.path.exists(f"./extgrps/{grpName}.cfg"): + grpfile += f"extgrps/{grpName}.cfg" + else: + print("could not find admins file!", file=stderr) try: - file = open(f"./wlgrps/{grpName}.cfg", 'rb') + file = open(grpfile, 'rb') + self.copyfile(file, self.wfile) + file.close() except: print('failed to open file!', file=stderr) - return - self.copyfile(file, self.wfile) - file.close() return