diff --git a/requirements.txt b/requirements.txt index c778b344c..4361dd180 100644 --- a/requirements.txt +++ b/requirements.txt @@ -35,7 +35,7 @@ redis pillow Jinja2>=2.11.2 PyMySQL>=1.0.2 -whitenoise==5.3.0 +whitenoise>5.3.0 tldextract pyotp pytz @@ -46,3 +46,7 @@ pyyaml croniter bcrypt packaging +Flask-Compress +brotli +zstd +zstandard \ No newline at end of file diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index 87e2d12a6..57a502216 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -377,6 +377,7 @@ mw_install(){ mw_common_proxy echo "bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh")" bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh") + mw_clean_lib bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh") } @@ -401,8 +402,8 @@ mw_update_dev() mw_common_proxy echo "bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh")" + mw_clean_lib bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh") - cd ${PANEL_DIR} } diff --git a/web/admin/__init__.py b/web/admin/__init__.py index 8d45f3ab7..8993de6b0 100644 --- a/web/admin/__init__.py +++ b/web/admin/__init__.py @@ -24,6 +24,7 @@ from flask import Response from flask import Flask, abort, current_app, session, url_for from flask import Blueprint, render_template from flask import render_template_string +from flask_compress import Compress from flask_socketio import SocketIO, emit, send @@ -44,15 +45,23 @@ setup.init() app = Flask(__name__, template_folder='templates/default') + +# curl --compressed -I "http://127.0.0.1:44010/" -H "Accept-Encoding: zstd" --write-out "%{json}" +app.config["COMPRESS_ALGORITHM"] = ["zstd", "br", "gzip", "deflate"] +Compress(app) + # 缓存配置 cache = Cache(config={'CACHE_TYPE': 'simple'}) cache.init_app(app, config={'CACHE_TYPE': 'simple'}) # 静态文件配置 -from whitenoise import WhiteNoise -app.wsgi_app = WhiteNoise(app.wsgi_app, root="../web/static/", prefix="static/", max_age=604800) +app.static_folder = "../static" +app.static_url_path = "/static" app.jinja_env.trim_blocks = True +# from whitenoise import WhiteNoise +# app.wsgi_app = WhiteNoise(app.wsgi_app, root="../web/static/", prefix="static/", max_age=604800) + # session配置 # app.secret_key = uuid.UUID(int=uuid.getnode()).hex[-12:] app.config['SECRET_KEY'] = uuid.UUID(int=uuid.getnode()).hex[-12:]