-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
41 lines (30 loc) · 1.04 KB
/
config.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
from dotenv import load_dotenv
from pathlib import Path
base_dir = Path(__file__).resolve().parent
env_file = base_dir / '.env'
load_dotenv(env_file)
class Config:
SECRET_KEY = os.environ.get('SECRET_KEY')
SQLALCHEMY_DATABASE_URI = ''
SQLALCHEMY_TRACK_MODIFICATIONS = False
PER_PAGE = 5
JWT_EXPIRED_MINUTES = 30
class DevelopmentConfig(Config):
SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI')
class TestingConfig(Config):
DB_FILE_PATH = base_dir / 'tests' / 'test.db'
SQLALCHEMY_DATABASE_URI = f'sqlite:///{DB_FILE_PATH}'
DEBUG = True
TESTING = True
class ProductionConfig(Config):
DB_HOST = os.environ.get('DB_HOST')
DB_USERNAME = os.environ.get('DB_USERNAME')
DB_PASSWORD = os.environ.get('DB_PASSWORD')
DB_NAME = os.environ.get('DB_NAME')
SQLALCHEMY_DATABASE_URI = f'mysql+pymysql://{DB_USERNAME}:{DB_PASSWORD}@{DB_HOST}/{DB_NAME}?charset=utf8mb4'
config = {
'development': DevelopmentConfig,
'testing': TestingConfig,
'production': ProductionConfig
}