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:
Charlotte Weaver
2019-04-22 12:24:07 -07:00
committed by GitHub
parent 1f735abe2b
commit 9c6273eb94
10 changed files with 171 additions and 60 deletions
+21 -19
View File
@@ -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