mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-04 11:08:11 +08:00
core library (#711)
* move app creation to function * create engine without load * flake 8 fixes * cleanup original scanpy test * add default config * handle missing data * test data changes * unify update * load data isn't static anymore * make app a class
This commit is contained in:
+21
-19
@@ -5,27 +5,29 @@ from flask_caching import Cache
|
||||
from flask_compress import Compress
|
||||
from flask_cors import CORS
|
||||
|
||||
from .rest_api.rest import get_api_resources
|
||||
from .util.utils import Float32JSONEncoder
|
||||
from .web import webapp
|
||||
from server.app.rest_api.rest import get_api_resources
|
||||
from server.app.util.utils import Float32JSONEncoder
|
||||
from server.app.web import webapp
|
||||
|
||||
REACTIVE_LIMIT = 1_000_000
|
||||
|
||||
app = Flask(__name__, static_folder="web/static")
|
||||
app.json_encoder = Float32JSONEncoder
|
||||
cache = Cache(app, config={"CACHE_TYPE": "simple", "CACHE_DEFAULT_TIMEOUT": 860_000})
|
||||
Compress(app)
|
||||
CORS(app)
|
||||
class Server:
|
||||
def __init__(self):
|
||||
self.data = None
|
||||
self.cache = Cache(config={"CACHE_TYPE": "simple", "CACHE_DEFAULT_TIMEOUT": 860_000})
|
||||
|
||||
# Config
|
||||
SECRET_KEY = os.environ.get("CXG_SECRET_KEY", default="SparkleAndShine")
|
||||
def create_app(self):
|
||||
app = Flask(__name__, static_folder="web/static")
|
||||
app.json_encoder = Float32JSONEncoder
|
||||
self.cache.init_app(app)
|
||||
Compress(app)
|
||||
CORS(app)
|
||||
|
||||
app.config.update(SECRET_KEY=SECRET_KEY)
|
||||
# Config
|
||||
SECRET_KEY = os.environ.get("CXG_SECRET_KEY", default="SparkleAndShine")
|
||||
app.config.update(SECRET_KEY=SECRET_KEY)
|
||||
|
||||
# Application Data
|
||||
data = None
|
||||
|
||||
resources = get_api_resources()
|
||||
app.register_blueprint(webapp.bp)
|
||||
app.register_blueprint(resources.blueprint)
|
||||
app.add_url_rule("/", endpoint="index")
|
||||
resources = get_api_resources()
|
||||
app.register_blueprint(webapp.bp)
|
||||
app.register_blueprint(resources.blueprint)
|
||||
app.add_url_rule("/", endpoint="index")
|
||||
return app
|
||||
|
||||
Reference in New Issue
Block a user