diff --git a/server/app/app.py b/server/app/app.py index 1330774e..639a6b2a 100644 --- a/server/app/app.py +++ b/server/app/app.py @@ -4,8 +4,6 @@ import logging from flask import Flask, redirect, current_app, make_response, render_template, abort from flask import Blueprint, request, send_from_directory -from flask_caching import Cache -from flask_compress import Compress from flask_cors import CORS from flask_restful import Api, Resource @@ -208,10 +206,6 @@ class Server: self.app = Flask(__name__, static_folder="../common/web/static") self.app.json_encoder = Float32JSONEncoder - self.cache = Cache(config={"CACHE_TYPE": "simple", "CACHE_DEFAULT_TIMEOUT": 860_000}) - self.cache.init_app(self.app) - - Compress(self.app) CORS(self.app, supports_credentials=True) # enable session data diff --git a/server/cli/launch.py b/server/cli/launch.py index e36e1b8b..06523ee8 100644 --- a/server/cli/launch.py +++ b/server/cli/launch.py @@ -6,12 +6,14 @@ import sys import webbrowser import click +from flask_compress import Compress from server.common.utils import sort_options from server.common.errors import DatasetAccessError, ConfigurationError from server.data_common.matrix_loader import MatrixDataCacheManager from server.common.app_config import AppConfig from server.common.default_config import default_config +from server.app.app import Server DEFAULT_CONFIG = AppConfig() @@ -268,6 +270,24 @@ def handle_scripts(scripts): click.confirm(f"Are you sure you want to inject these scripts: {scripts_pretty}?", abort=True) +class CliLaunchServer(Server): + """ + the CLI runs a local web server, and needs to enable a few more features. + """ + def __init__(self, matrix_data_cache_manager, annotations, app_config): + super().__init__(matrix_data_cache_manager, annotations, app_config) + self.app.config["COMPRESS_MIMETYPES"] = [ + "text/html", + "text/css", + "text/xml", + "application/json", + "application/javascript", + "application/octet-stream", + ] + compress = Compress(self.app) + compress.init_app(self.app) + + @sort_options @click.command( short_help="Launch the cellxgene data viewer. " "Run `cellxgene launch --help` for more information.", @@ -377,9 +397,7 @@ def launch( user_annotations = app_config.user_annotations # create the server - from server.app.app import Server - - server = Server(matrix_data_cache_manager, user_annotations, app_config) + server = CliLaunchServer(matrix_data_cache_manager, user_annotations, app_config) if not app_config.server__verbose: log = logging.getLogger("werkzeug") diff --git a/server/requirements.txt b/server/requirements.txt index 69ea7553..a9713b22 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -2,7 +2,6 @@ anndata>=0.6.20 click>=6.7 fastobo>=0.6.1 Flask>=1.0.2 -Flask-Caching>=1.4.0 Flask-Compress>=1.4.0 Flask-Cors>=3.0.6 Flask-RESTful>=0.3.6