aboutsummaryrefslogtreecommitdiff
path: root/gn3/app.py
blob: e9ce7f1d9bfa63f0ac9f274d69a84c3448b6d532 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Entry point from spinning up flask"""
import os

from typing import Dict
from typing import Union
from flask import Flask

from gn3.api.gemma import gemma

def create_app(config: Union[Dict, str, None] = None) -> Flask:
    """Create a new flask object"""
    app = Flask(__name__)
    # Load default configuration
    app.config.from_object("gn3.settings")

    # Load environment configuration
    if "GN3_CONF" in os.environ:
        app.config.from_envvar('GN3_CONF')

    # Load app specified configuration
    if config is not None:
        if isinstance(config, dict):
            app.config.update(config)
        elif config.endswith(".py"):
            app.config.from_pyfile(config)
    app.register_blueprint(gemma, url_prefix="/gemma")
    return app