mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
feat: support HTTP response compression in api server (#2680)
This commit is contained in:
parent
38e5952417
commit
552f319b9d
|
@ -26,6 +26,7 @@ from config import CloudEditionConfig, Config
|
||||||
from extensions import (
|
from extensions import (
|
||||||
ext_celery,
|
ext_celery,
|
||||||
ext_code_based_extension,
|
ext_code_based_extension,
|
||||||
|
ext_compress,
|
||||||
ext_database,
|
ext_database,
|
||||||
ext_hosting_provider,
|
ext_hosting_provider,
|
||||||
ext_login,
|
ext_login,
|
||||||
|
@ -96,6 +97,7 @@ def create_app(test_config=None) -> Flask:
|
||||||
def initialize_extensions(app):
|
def initialize_extensions(app):
|
||||||
# Since the application instance is now created, pass it to each Flask
|
# Since the application instance is now created, pass it to each Flask
|
||||||
# extension instance to bind it to the Flask application instance (app)
|
# extension instance to bind it to the Flask application instance (app)
|
||||||
|
ext_compress.init_app(app)
|
||||||
ext_code_based_extension.init()
|
ext_code_based_extension.init()
|
||||||
ext_database.init_app(app)
|
ext_database.init_app(app)
|
||||||
ext_migrate.init(app, db)
|
ext_migrate.init(app, db)
|
||||||
|
|
|
@ -293,6 +293,8 @@ class Config:
|
||||||
|
|
||||||
self.BATCH_UPLOAD_LIMIT = get_env('BATCH_UPLOAD_LIMIT')
|
self.BATCH_UPLOAD_LIMIT = get_env('BATCH_UPLOAD_LIMIT')
|
||||||
|
|
||||||
|
self.API_COMPRESSION_ENABLED = get_bool_env('API_COMPRESSION_ENABLED')
|
||||||
|
|
||||||
|
|
||||||
class CloudEditionConfig(Config):
|
class CloudEditionConfig(Config):
|
||||||
|
|
||||||
|
|
10
api/extensions/ext_compress.py
Normal file
10
api/extensions/ext_compress.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from flask import Flask
|
||||||
|
|
||||||
|
|
||||||
|
def init_app(app: Flask):
|
||||||
|
if app.config.get('API_COMPRESSION_ENABLED', False):
|
||||||
|
from flask_compress import Compress
|
||||||
|
|
||||||
|
compress = Compress()
|
||||||
|
compress.init_app(app)
|
||||||
|
|
|
@ -3,6 +3,7 @@ beautifulsoup4==4.12.2
|
||||||
flask~=3.0.1
|
flask~=3.0.1
|
||||||
Flask-SQLAlchemy~=3.0.5
|
Flask-SQLAlchemy~=3.0.5
|
||||||
SQLAlchemy~=1.4.28
|
SQLAlchemy~=1.4.28
|
||||||
|
Flask-Compress~=1.14
|
||||||
flask-login~=0.6.3
|
flask-login~=0.6.3
|
||||||
flask-migrate~=4.0.5
|
flask-migrate~=4.0.5
|
||||||
flask-restful~=0.3.10
|
flask-restful~=0.3.10
|
||||||
|
|
Loading…
Reference in New Issue
Block a user