Switch to Waitress and Flask-Compress in lieu of werkzeug server

This commit is contained in:
Miguel Jacq 2023-05-29 14:46:17 +10:00
parent 8528698971
commit f50a552df4
5 changed files with 342 additions and 231 deletions

View file

@ -181,7 +181,6 @@ class ShareModeWeb(SendBaseModeWeb):
# Prepare some variables to use inside generate() function below
# which is outside of the request context
shutdown_func = request.environ.get("werkzeug.server.shutdown")
request_path = request.path
# If this is a zipped file, then serve as-is. If it's not zipped, then,
@ -218,7 +217,6 @@ class ShareModeWeb(SendBaseModeWeb):
else:
r = Response(
self.generate(
shutdown_func,
range_,
file_to_download,
request_path,
@ -303,7 +301,7 @@ class ShareModeWeb(SendBaseModeWeb):
return range_, status_code
def generate(
self, shutdown_func, range_, file_to_download, path, history_id, filesize
self, range_, file_to_download, path, history_id, filesize
):
# The user hasn't canceled the download
self.client_cancel = False
@ -390,9 +388,7 @@ class ShareModeWeb(SendBaseModeWeb):
print("Stopped because transfer is complete")
self.web.running = False
try:
if shutdown_func is None:
raise RuntimeError("Not running with the Werkzeug Server")
shutdown_func()
self.web.stop()
except Exception:
pass