From 1747e55549a3e7c7e019ae0630f774c1b39b78a7 Mon Sep 17 00:00:00 2001 From: Skillet Date: Thu, 7 Sep 2023 20:00:12 -0400 Subject: [PATCH] update to threading server --- simpleFileServer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/simpleFileServer.py b/simpleFileServer.py index 89c617d..3262578 100644 --- a/simpleFileServer.py +++ b/simpleFileServer.py @@ -46,9 +46,9 @@ class serveRA(http.server.SimpleHTTPRequestHandler): for congrp in confgrps: responsetext = re.sub(rf"^Group=({congrp[0]}):(.+)", rf"Group=\1:{congrp[1]}", responsetext, flags=re.M) self.wfile.write(responsetext.encode('utf-8')) - backupfile = open(f"./wlgrps/backup-{grpName}.cfg", 'wb') - backupfile.write(responsetext.encode('utf-8')) - backupfile.close() + with open(f"./wlgrps/backup-{grpName}.cfg", 'wb') as backupfile: + backupfile.write(responsetext.encode('utf-8')) + backupfile.close() else: backupfile = open(f"./wlgrps/backup-{grpName}.cfg", 'rb') self.copyfile(backupfile, self.wfile) @@ -70,7 +70,7 @@ def startServer(): while True: print("trying to start...") try: - with socketserver.TCPServer(("", PORT), handler) as httpd: + with socketserver.ThreadingTCPServer(("", PORT), handler) as httpd: print('starting server!') httpd.serve_forever() except: