Completed
Push — master ( 621df3...0c6719 )
by Ronert
12:32
created

cf_predict.ProductionConfig.init_app()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4285
cc 1
1
import json
2
import logging
3
import os
4
5
6
basedir = os.path.abspath(os.path.dirname(__file__))
7
8
9
class Config:
10
    @classmethod
11
    def init_app(cls, app):
12
        """Send logs to stdout."""
13
        file_handler = logging.StreamHandler()
14
        file_handler.setLevel(logging.WARNING)
15
        app.logger.addHandler(file_handler)
16
17
18
class DevelopmentConfig(Config):
19
    DEBUG = True
20
    HOST = "0.0.0.0"
21
    PORT = 5000
22
    DEBUG = True
23
24
25
class UnitTestingConfig(Config):
26
    TESTING = True
27
    HOST = "0.0.0.0"
28
    PORT = 5000
29
    DEBUG = True
30
31
32
class IntegrationTestingConfig(Config):
33
    TESTING = True
34
    DEBUG = True
35
36
37
class ProductionConfig(Config):
38
    if os.getenv("VCAP_SERVICES"):
39
        services = json.loads(os.getenv("VCAP_SERVICES"))
40
        redis_env = services["p-redis"][0]["credentials"]
41
        REDIS_URL = "redis://" + redis_env["password"] + "@" + redis_env["host"] + ":" + redis_env["port"]
42
43
44
config = {
45
    "development": DevelopmentConfig,
46
    "unit_testing": UnitTestingConfig,
47
    "integration_testing": IntegrationTestingConfig,
48
    "production": ProductionConfig,
49
    "default": DevelopmentConfig
50
}
51