7
7
import logging
8
8
9
9
10
- class Config :
11
- # API configurations
12
- SECRET_KEY = env_conf ("SECRET_KEY" )
13
- # Database configurations
14
- SQLALCHEMY_TRACK_MODIFICATIONS = False
15
- SQLALCHEMY_RECORD_QUERIES = True
16
-
17
- @staticmethod
18
- def init_app (app ):
19
- pass
20
-
21
-
22
- class LocalPSQLConfig (Config ):
10
+ class LocalPSQLConfig :
23
11
# To initate the local config. Basically adds bunch of logger handlers with
24
12
# a postgre sql setup
25
13
@@ -31,9 +19,13 @@ class LocalPSQLConfig(Config):
31
19
SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://{}:{}@{}:{}/{}' .\
32
20
format (DB_USER , DB_PASSWORD , DB_HOST , DB_PORT , DB_NAME )
33
21
22
+ SQLALCHEMY_TRACK_MODIFICATIONS = False
23
+ SQLALCHEMY_RECORD_QUERIES = True
24
+
25
+ SECRET_KEY = env_conf ("SECRET_KEY" , cast = str , default = "12345" )
26
+
34
27
@classmethod
35
28
def init_app (cls , app ):
36
- Config .init_app (app )
37
29
# The default Flask logger level is set at ERROR, so if you want to see
38
30
# INFO level or DEBUG level logs, you need to lower the main loggers
39
31
# level first.
@@ -42,31 +34,35 @@ def init_app(cls, app):
42
34
app .logger .addHandler (client_logger )
43
35
44
36
45
- class DockerPSQLConfig ( Config ) :
46
- # To initate the docker config. Basically adds bunch of logger handlers and
47
- # sets the database host configurations to run with the docker setup.
48
- DB_USER = ' deploy'
49
- DB_PASSWORD = ' docker'
50
- DB_HOST = 'db'
51
- DB_PORT = 5432
52
- DB_NAME = 'ftemplate'
53
- SQLALCHEMY_DATABASE_URI = ' postgresql+psycopg2://{}:{}@{}:{}/{}' .\
54
- format ( DB_USER , DB_PASSWORD , DB_HOST , DB_PORT , DB_NAME )
37
+ class Develop :
38
+ """Development config geared towards docker."""
39
+ # Database configurations
40
+ DB_USER = " deploy"
41
+ DB_PASSWORD = " docker"
42
+ DB_HOST = "db"
43
+ DB_PORT = " 5432"
44
+ DB_NAME = "stories"
45
+ SQLALCHEMY_DATABASE_URI = " postgresql+psycopg2://{}:{}@{}:{}/{}" . format (
46
+ DB_USER , DB_PASSWORD , DB_HOST , DB_PORT , DB_NAME )
55
47
56
- @classmethod
57
- def init_app (cls , app ):
58
- Config .init_app (app )
59
- # The default Flask logger level is set at ERROR, so if you want to see
60
- # INFO level or DEBUG level logs, you need to lower the main loggers
61
- # level first.
48
+ SQLALCHEMY_TRACK_MODIFICATIONS = False
49
+ SQLALCHEMY_RECORD_QUERIES = True
50
+
51
+ # DEBUG = True
52
+ # API configurations
53
+ SECRET_KEY = env_conf ("SECRET_KEY" , cast = str , default = "12345" )
54
+
55
+ @staticmethod
56
+ def init_app (app ):
57
+ """Initiates application."""
62
58
app .logger .setLevel (logging .DEBUG )
63
- app .logger .addHandler (file_logger )
64
59
app .logger .addHandler (client_logger )
60
+ app .logger .addHandler (file_logger )
65
61
66
62
67
63
# Create a config dictionary which is used while initiating the application.
68
64
# Config that is going to be used will be specified in the .env file
69
65
config_dict = {
70
- 'local ' : LocalPSQLConfig ,
71
- 'docker ' : DockerPSQLConfig ,
66
+ 'localpsql ' : LocalPSQLConfig ,
67
+ 'develop ' : Develop ,
72
68
}
0 commit comments